title: How can I automatically send email from Thunderbird with Excel VBA?
body: <p>What I want to do is send an email from a Thunderbird account automatically. The user shouldn't even have to hit the Send button of the email. </p>
  
  <p>I've tried using CDO, but the problem with it is that you have to input the username and password of the account you are sending from. This macro will be used from several different accounts, so inputting each username and password isn't feasible. I could use CDO if there was someway of retrieving the username, password, and smtp server from Thunderbird, but I feel like the code I already have should be able to accomplish this without CDO (hopefully). </p>
  
  <p>Here is really the only code I see (and it's everywhere) in regards to accomplishing this. </p>
  
  <pre><code>Sub Thunderbird()
  
  Dim thund As String      
  Dim email As String 
  Dim cc As String
  Dim bcc As String 
  Dim subj As String  
  Dim body As String     
  
  email = "email@test.com"
  cc = "cc@test.com"
  bcc = "bcc@test.com"
  subj = "Subject"
  body = "body text"
  
  thund = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe" 
  thund = thund &amp; " -compose " &amp; Chr$(34) &amp; "mailto:" &amp; email &amp; "?"
  thund = thund &amp; "cc=" &amp; Chr$(34) &amp; cc &amp; "?"
  thund = thund &amp; "bcc=" &amp; Chr$(34) &amp; bcc &amp; "?"
  thund = thund &amp; "subject=" &amp; Chr$(34) &amp; subj &amp; Chr$(34)
  thund = thund &amp; "body=" &amp; Chr$(34) &amp; body
  
  Call Shell(thund, vbNormalFocus)
  SendKeys "^+{ENTER}", True
  
  End Sub
  </code></pre>
  
  <p>As of right now, the fields <code>cc</code>, <code>bcc</code>, <code>subj</code>, and <code>body</code> are all recognized correctly. The problem is they all get added to the end of the first field. For instance, with the way the code is right now, <code>cc</code> will get put in the cc field, but <code>bcc</code>, <code>subj</code>, and <code>body</code> all get appended to <code>cc</code> in the cc field of Thunderbird. </p>
  
  <p>If I comment <code>cc</code> out, then <code>bcc</code> is put in the correct field, but <code>subj</code> and <code>body</code> get appended to <code>bcc</code> in the bcc field of Thunderbird. </p>
  
  <p>If I comment <code>cc</code> and <code>bcc</code> out, then <code>subj</code> gets put in the correct field, but <code>body</code> gets appended to <code>subj</code> in the subject field of Thunderbird. </p>
  
  <p>So basically I need to add the correct code at the end of each of these lines. I've tried both <code>"?"</code> and <code>Chr$(34)</code> to no avail. </p>
  
  <p>Lastly, <code>SendKeys "^+{ENTER}", True</code> isn't working at all. This might be because of all the parameters not being put in the correct field of Thunderbird, but not sure since I can't get that working. Email from Thunderbird displays, but this code isn't sending the email like it's supposed to. </p>
  
  <p><strong>SOLUTION</strong> (as provided by @zedfoxus)</p>
  
  <pre><code>Sub Thunderbird()
  
  Dim thund As String      
  Dim email As String 
  Dim cc As String
  Dim bcc As String 
  Dim subj As String  
  Dim body As String     
  
  email = "email@test.com"
  cc = "cc@test.com"
  bcc = "bcc@test.com"
  subj = "Subject"
  body = "body text"
  
  thund = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe" &amp; _
          " -compose " &amp; """" &amp; _
          "to='" &amp; email &amp; "'," &amp; _
          "cc='" &amp; cc &amp; "'," &amp; _
          "bcc='" &amp; bcc &amp; "'," &amp; _
          "subject='" &amp; subj &amp; "'," &amp; _
          "body='" &amp; body &amp; "'" &amp; """"
  
  Call Shell(thund, vbNormalFocus)
  Application.Wait (Now + TimeValue("0:00:03"))
  SendKeys "^{ENTER}", True
  
  End Sub
  </code></pre>