Solved

Sending Mail Attachments in Delphi

Posted on 1997-12-12
3
449 Views
Last Modified: 2012-05-07
I know this is a big question.

I would like to know how to send a mail message with a MAPI encoded attachment in Delphi.
Please do not direct me to third party controls that are not free and available on the internet.
I need to send it in Microsoft Exchange format.

I know the scope of the question which is why I have put so many points out.

I few pointers might be all I need to do this.
The attached document will be in Word95 format, not that it should be significant.

my email address is craig-m@iafrica.com should you wish to mail me.

Thanks
Regards
Craig.
0
Comment
Question by:cmain
3 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 350 total points
Comment Utility
The following code sends a message and attachment from Fred to John.  (Add mapi to the uses clause.)

var
  Originator, Recipient: TMapiRecipDesc;
  FileAttachment: TMapiFileDesc;
  MapiMsg: TMapiMessage;
begin
  if (MapiLogOn(0, nil, nil, MAPI_LOGON_UI or MAPI_NEW_SESSION , 0, @hMapi) = SUCCESS_SUCCESS) then
    begin
      FillChar(MapiMsg, SizeOf(TMapiMessage), 0);

      MapiMsg.lpszSubject := 'Test Message';
      MapiMsg.lpszNoteText := ' Hello.  This is the message text.  The End.';
      MapiMsg.flFlags := MAPI_RECEIPT_REQUESTED;

      FillChar(Originator, SizeOf(TMapiRecipDesc), 0);
      Originator.lpszName := 'Fred';
      Originator.lpszAddress := 'SMTP:fred@freddy.com';
      Originator.ulRecipClass := MAPI_ORIG;
      MapiMsg.lpOriginator := @Originator;

      MapiMsg.nRecipCount := 1;
      FillChar(Recipient, SizeOf(TMapiRecipDesc), 0);
      Recipient.lpszName := 'John';
      Recipient.lpszAddress := 'SMTP:john@johnny.com';
      Recipient.ulRecipClass := MAPI_TO;
      MapiMsg.lpRecips := @Recipient;

      MapiMsg.nFileCount := 1;
      FillChar(FileAttachment, SizeOf(TMapiFileDesc), 0);
      FileAttachment.flFlags := 0;
      FileAttachment.lpszPathName := 'C:\autoexec.bat';
      FileAttachment.lpszFileName := 'autoexec.bat';
      MapiMsg.lpFiles := @FileAttachment;

      MapiSendMail(hMapi, 0, MapiMsg, MAPI_LOGON_UI, 0);

      MapiLogOff(hMapi, 0, 0, 0);
    end;
end;

0
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
This is freeware, easy, everything is possible, lot's of documenation, with source, for ALL delphi versions, for EVERY platform and good. But JimBob's answer is also correct.

Look at :

 SunSite.icm.edu.pl/delphi/ftp/d10free/temail2.zip

It's really recommended just to have a look at it.

Have fun,
c.u. ZifNab;
0
 
LVL 1

Author Comment

by:cmain
Comment Utility
Thanks David.

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now