Solved

Sending Mail Attachments in Delphi

Posted on 1997-12-12
3
476 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 350 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

624 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