Board index » delphi » sending an e-mail with an attached file

sending an e-mail with an attached file

I'm using the code below to call the default e-mail manager so the user can send one e-mail:

hnd := ShellExecute(handle, 'open', 'mailto:n...@location.com', '', '', SW_SHOWNA);

The question is: How can I launch the default messenger with a file attached to the e-mail?

Thanks for all help.
Luis Rocha

--

Luis Fernando Nacif Rocha
lfnacif...@terra.com.br - Brazil

"Grandes e admiraveis sao as tuas obras, Senhor Deus, Todo-Poderoso!
Justos e verdadeiros sao os teus caminhos, oh Rei das nacoes!" Ap 15:3

"Great and marvelous are your deeds, Lord God Almighty.
Just and true are your ways, King of the ages." Rev. 15:3

 

Re:sending an e-mail with an attached file


Luis Fernando Nacif Rocha <lfnacif...@terra.com.br> wrote in message
news:3B8E8352.D7BA0A9C@terra.com.br...

Quote
> I'm using the code below to call the default e-mail manager so the user

can send one e-mail:
Quote

> hnd := ShellExecute(handle, 'open', 'mailto:n...@location.com', '', '',
SW_SHOWNA);

> The question is: How can I launch the default messenger with a file

attached to the e-mail?
Quote

> Thanks for all help.
> Luis Rocha

> --

> Luis Fernando Nacif Rocha
> lfnacif...@terra.com.br - Brazil

> "Grandes e admiraveis sao as tuas obras, Senhor Deus, Todo-Poderoso!
> Justos e verdadeiros sao os teus caminhos, oh Rei das nacoes!" Ap 15:3

> "Great and marvelous are your deeds, Lord God Almighty.
> Just and true are your ways, King of the ages." Rev. 15:3

Daniel Bragg suggested today in the objectpascal NG using:

    &Att:filename="ATTACH.TXT"
(see thread 'Import a text file into a email form')

Using this you could modify your code thus:
...
var
  strEmailAddress, strSubject, strBodyText,  strAttachment, strMsg: string;
 (*  i: Integer; *)
begin
...
strEmailAddress := 'some...@someplace.com';
strSubject := 'Subject of message ...';
strBodyText := 'Text of message ...';
strAttachment := 'ATTACH.TXT';

strMsg := 'mailto:' + strEmailAddress +
               '?subject=' + strSubject +
               '&Body=' +  strBodyText' +
               '&Att:filename=' + strAttachment;

ShellExecute(handle, 'open', PChar(strMsg), nil, nil, SW_SHOWNORMAL);
...
end;

Worth trying
hth
Jeff

Re:sending an e-mail with an attached file


Does this work only with text files? I need to send pictures, like a bitmap. Is there a way to do it calling the browser or mail manager? (like Winzip, with the "zip and
e-mail" feature).

Quote
Jeff Llewellyn wrote:
> Daniel Bragg suggested today in the objectpascal NG using:

>     &Att:filename="ATTACH.TXT"
> (see thread 'Import a text file into a email form')

> Using this you could modify your code thus:
> ...
> var
>   strEmailAddress, strSubject, strBodyText,  strAttachment, strMsg: string;
>  (*  i: Integer; *)
> begin
> ...
> strEmailAddress := 'some...@someplace.com';
> strSubject := 'Subject of message ...';
> strBodyText := 'Text of message ...';
> strAttachment := 'ATTACH.TXT';

> strMsg := 'mailto:' + strEmailAddress +
>                '?subject=' + strSubject +
>                '&Body=' +  strBodyText' +
>                '&Att:filename=' + strAttachment;

> ShellExecute(handle, 'open', PChar(strMsg), nil, nil, SW_SHOWNORMAL);
> ...
> end;

> Worth trying
> hth
> Jeff

--

Luis Fernando Nacif Rocha
lfnacif...@terra.com.br - Brazil

"Grandes e admiraveis sao as tuas obras, Senhor Deus, Todo-Poderoso!
Justos e verdadeiros sao os teus caminhos, oh Rei das nacoes!" Ap 15:3

"Great and marvelous are your deeds, Lord God Almighty.
Just and true are your ways, King of the ages." Rev. 15:3

Re:sending an e-mail with an attached file


I'm making the assumption that using &Att:filename="ATTACH.XYZ" will achieve
in code the same result as physically inserting *any* file as an
attachment - so it should work for bitmaps etc.

Jeff

Luis Fernando Nacif Rocha <lfnacif...@terra.com.br> wrote in message
news:3B95575D.D05F2906@terra.com.br...

Quote
> Does this work only with text files? I need to send pictures, like a

bitmap. Is there a way to do it calling the browser or mail manager? (like
Winzip, with the "zip and
Quote
> e-mail" feature).

> Jeff Llewellyn wrote:

> > Daniel Bragg suggested today in the objectpascal NG using:

> >     &Att:filename="ATTACH.TXT"
> > (see thread 'Import a text file into a email form')

> > Using this you could modify your code thus:
> > ...
> > var
> >   strEmailAddress, strSubject, strBodyText,  strAttachment, strMsg:
string;
> >  (*  i: Integer; *)
> > begin
> > ...
> > strEmailAddress := 'some...@someplace.com';
> > strSubject := 'Subject of message ...';
> > strBodyText := 'Text of message ...';
> > strAttachment := 'ATTACH.TXT';

> > strMsg := 'mailto:' + strEmailAddress +
> >                '?subject=' + strSubject +
> >                '&Body=' +  strBodyText' +
> >                '&Att:filename=' + strAttachment;

> > ShellExecute(handle, 'open', PChar(strMsg), nil, nil, SW_SHOWNORMAL);
> > ...
> > end;

> > Worth trying
> > hth
> > Jeff

> --

> Luis Fernando Nacif Rocha
> lfnacif...@terra.com.br - Brazil

> "Grandes e admiraveis sao as tuas obras, Senhor Deus, Todo-Poderoso!
> Justos e verdadeiros sao os teus caminhos, oh Rei das nacoes!" Ap 15:3

> "Great and marvelous are your deeds, Lord God Almighty.
> Just and true are your ways, King of the ages." Rev. 15:3

Other Threads