Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sending Mail Attachments in Delphi

Posted on 1997-12-12
3
Medium Priority
?
477 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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 this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

722 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