Delphi 发送邮件 通过Office Outlook

   Delphi 发送邮件 通过Office Outlook


       网上搜到的Delphi邮件发送系统,绝大多数是使用SMTP协议来发送。

但是事实上它们已经过时了,大多数邮件服务器已经屏蔽了Delphi Indy的邮件发送,从而导致Delphi发送不成功。

事实上,让Delphi通过Outlook.Application来发送邮件,也是非常方便的,而且没有那么多的限制。

以下是我目前使用的,我把它写成了个函数,使用的时候调用一下即可。

不过,使用的前提是,你得现在在本地Outlook上配置好一个账户。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
procedure TForm1 . SendOutlookMail( const Recipient,Title,Body,Attachment: string );
     const
        olMailItem =  0 ;
     var
        Outlook: OleVariant;
        vMailItem: variant;
     begin
        try
           Outlook := GetActiveOleObject("Outlook . Application");
        except
           Outlook := CreateOleObject("Outlook . Application");
        end ;
        vMailItem := Outlook . CreateItem(olMailItem);
        vMailItem . Recipients . Add(Recipient);
        vMailItem . Subject := Title;
        vMailItem . Body := Body;
        if Attachment <>""  then vMailItem . Attachments . Add(Attachment);
        vMailItem . Send;
        VarClear(Outlook);

delphi发送邮件

 

转载于:https://www.cnblogs.com/m0488/p/6609881.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值