wie kann ich an outlook oder outlook exress eine datei anhängen um diese dann zu verschicken
Announcement
Collapse
No announcement yet.
e-attchment
Collapse
X
-
Hallo,
ein Datei-Anhang muss als Objekt der Kollektion <b>Attachments</b> hinzugefügt werden. Das folgende Beispiel stammt aus einer universellen DLL-Funktion:
<pre>
function E_SendDocAsMail(const pRecipient, pTitle, pMsg, pFile: PChar;
iRECEIPT : Integer): Integer; stdcall;
resourcestring
cMsg1 = 'Illegale eMail-Daten!';
cMsg2 = 'Microsoft Outlook 2000 nicht gefunden!';
cMsg3 = 'eMail konnte nicht über Outlook 2000 verschickt werden';
var
sMsg : String;
swRecipent: WideString;
swTitle : WideString;
swBody : WideString;
vFile : OleVariant;
aOutlook : _Application;
aMAPI : NameSpace;
aOutbox : MAPIFolder;
aMail : MailItem;
aReci : Recipient;
begin
Result := 1;
try
sMsg := cMsg2;
swRecipent := pRecipient;
swTitle := pTitle;
swBody := pMsg;
vFile := StrPas(pFile);
sMsg := cMsg2;
aOutLook := CoOutlookApplication.Create;
sMsg := cMsg3;
try
aMAPI := aOutlook.GetNameSpace('MAPI');
aOutbox := aMAPI.GetDefaultFolder(olFolderOutbox);
aMail := aOutbox.Items.Add(olMailItem) as MailItem;
aReci := aMail.Recipients.Add(swRecipent);
aReci.Type_ := olTo;
aMail.Subject := swTitle;
aMail.Body := swBody;
aMail.Attachments.Add(vFile, EmptyParam, EmptyParam, EmptyParam);
if iRECEIPT = 1 then
aMail.ReadReceiptRequested := True;
aMail.Send;
finally
aOutlook := nil;
end;
except
ShowExceptionMsg(sMsg);
Result := 0;
end;
end;
</pre>
Comment