Отправить Email через Outlook

Советы » Почтовый клиент » Отправить Email через Outlook

uses

ComObj; procedure

TForm1.Button16Click(Sender: TObject); const

olMailItem = 0; olByValue = 1; var

OutlookApp, MailItem, MyAttachments: OLEVariant; begin

try

OutlookApp := GetActiveOleObject('Outlook.Application'); except

OutlookApp := CreateOleObject('Outlook.Application'); end

; try

MailItem := OutlookApp.CreateItem(olMailItem); MailItem.Recipients.Add('YourMailAddress@something.com'); MailItem.Subject := 'Your Subject'; MailItem.Body := 'Your Message'; myAttachments := MailItem.Attachments; myAttachments.Add('C:SomeFile.txt', olByValue, 1, 'Name of Attachment'); MailItem.Send; finally

myAttachments := VarNull; OutlookApp := VarNull; end

; end

;

Другое по теме:

Категории

Статьи

Советы

Copyright © 2022 - All Rights Reserved - www.delphirus.com