sending EMails with Delphi XE2 TMailItem

Hi everybody,

I developped an application with D7 that can send emails using outlook. Now I need to compile this application in Delphi XE2 but the object "TMailItem" is no longer defined (undeclared object). Which unit I have to import or what is the new way to do this job? Thanks for aour help, Peter
formiAsked:
Who is Participating?
 
ThommyCommented:
Use late binding for outlook automation...

Send an email (with attachment) from Outlook
http://delphi.about.com/cs/adptips2000/a/bltip0800_3.htm
0
 
formiAuthor Commented:
Thanks, thats a possible way. I found that I have to use the type MapiItem instead of TMaipItem.
0
 
formiAuthor Commented:
possible solution but not what I needed to know.
0
 
rinfoCommented:
Since XE TmailItem is replaced with mailitem.
However as reported in forums mailterm is not being recognized as object type and wokaround have been used successfully.
Var
Outlook: OleVariant;
vMailItem: variant;
mRecipient, mSubject, mBody, mAttachement : String;
begin

//Procedure SendEMail(mRecipient:String, mSubject:String, mBody:String, mAttachement:String);
try
Outlook := GetActiveOleObject('Outlook.Application');
except
Outlook := CreateOleObject('Outlook.Application');
end;
vMailItem := Outlook.CreateItem(olMailItem);
vMailItem.Recipients.Add(mRecipient);
vMailItem.Subject := mSubject;
vMailItem.Body := mBody;
vMailItem.Attachments.Add(mAttachement);
vMailItem.Send;

VarClear(Outlook);

end;

end.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.