Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sending Mail Attachments in Delphi

Posted on 1997-12-12
3
Medium Priority
?
487 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 1400 total points
ID: 1353472
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
ID: 1353473
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
ID: 1353474
Thanks David.

0

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

916 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