#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    177
    Rep Power
    40

    Email using Thunderbird


    I have an applciation where i want to send a normal email with an attachment via thunderbird.
    Using Outlook seems easy. I got that to work. Some of my clients use thunderbird. I like to get this working here as well.
    I dont want to rely on the DEFAULT emailing program in windows. It does not always work. I found one solution but dont get it working at all. Compling error.


    Code:
     ShellExecute(Handle, 'path\to\thunderbird.exe',
        '-compose "to=foo@nowhere.net,attachment=''file:///c:/test.txt''", 
        nil, SW_SHOWNORMAL);
    Is there is simple way? The above code i cannot get working. I get an error. Incompatibe types integer and widestring.
    If shellexcute does not work is there any other ideas?

    Please can someone help?

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    397
    Rep Power
    0
    I don't have thunderbird to actually test this, but try this:
    Code:
    Filename := 'c:\path\to\thunderbird.exe';
    Parameters := '-compose "to=''foo@nowhere.net'',attachment=''file:///c:/test.txt''"';
    ShellExecute(handle,'open', PChar(Filename), PChar(Parameters), '', SW_SHOWNORMAL);
    All the parameters you can send to Thunderbird can be found here: Command line arguments - Thunderbird - MozillaZine Knowledge Base
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    177
    Rep Power
    40
    Originally Posted by majlumbo
    I don't have thunderbird to actually test this, but try this:
    Code:
    Filename := 'c:\path\to\thunderbird.exe';
    Parameters := '-compose "to=''foo@nowhere.net'',attachment=''file:///c:/test.txt''"';
    ShellExecute(handle,'open', PChar(Filename), PChar(Parameters), '', SW_SHOWNORMAL);
    All the parameters you can send to Thunderbird can be found here: Command line arguments - Thunderbird - MozillaZine Knowledge Base

    Thanks all seems to work. Including the parameters. So i want to build code around it. Sometimes i want to send the email DIRECTLY (without the popup).
    Is there anyway we can do that? I did some research but i guess it is not possible right? Then what do one do if the user installed thunderbird in a different path?
    Lets say one has a 64 bit machine. Another a 32 bit. Or even installed it on a different drive than C. There is no way i can pick thunderbird without the direct path?
    I have this code for OUTLOOK wich works great. Looking for something similiar?

    Code:
    const
      olMailItem = 0;
    
    begin
      try
        Outlook := GetActiveOleObject('Outlook.Application');
      except
        Outlook := CreateOleObject('Outlook.Application');
      end;
      MailItem := Outlook.CreateItem(olMailItem);
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    397
    Rep Power
    0
    I want to send the email DIRECTLY (without the popup). Is there anyway we can do that?
    Not that I'm aware of. This was a security feature Microsoft implemented to stop applications from sending e-mails out without a user's knowledge.

    Then what do one do if the user installed thunderbird in a different path?
    Thunderbird apparently does not support COM interfaces, so automating thunderbird as you did with Outlook via COM is not an alternative, they do (according to this: Calling Thunderbird from other programs - MozillaZine Knowledge Base) support XPCOM (Cross Platform Component Object Model).

    I did find a Delphi wrapper to XPCOM here: Gecko SDK for Delphi / Code / [r17]
    but have never used it, so can't tell you if it'll solve your particular issue.

IMN logo majestic logo threadwatch logo seochat tools logo