使用powerbuilder实现邮箱发送

首先MyMail.dll文件,这个在网上找一大推。
然后引入
function int MyUtil_POP3_Connect(string host,int port,string UserId,string PassWord,string AttachPath) library “MyMail.dll” alias for “MyUtil_POP3_Connect;ansi”
Function int MyUtil_POP3_Disconnect() library “MyMail.dll”
Function int MyUtil_POP3_Msg_GetInfo(int i_type,int i_sub_type, ref string as_text) library “MyMail.dll” alias for “MyUtil_POP3_Msg_GetInfo;ansi”

function int MyUtil_SMTP_Connect(string host,int port,string UserId,string PassWord) library “MyMail.dll” alias for “MyUtil_SMTP_Connect;ansi”
function int MyUtil_SMTP_Msg_Init() library “MyMail.dll”
function int MyUtil_SMTP_Disconnect() library “MyMail.dll”
function int MyUtil_SMTP_Msg_SetInfo(int i_type,int i_sub_type,string as_text) library “MyMail.dll” alias for “MyUtil_SMTP_Msg_SetInfo;ansi”
function int MyUtil_SMTP_Msg_Send() library “MyMail.dll” alias for “MyUtil_SMTP_Msg_Send;ansi”

下面是代码
string host,uid,pwd
int port,ret
host=“xxxxx.com” //服务器名
uid=“xxx@xx.com” //发件人登陆发件服务器时的用户名
pwd=“123456” //发件人登陆发件服务器时的密码
port=25 //发送服务器的smtp端口号,没改的话一般是25

//邮件初始化
if MyUtil_SMTP_Msg_Init()<0 then
MessageBox(gs_title,“邮件初始化失败”);
end if

//发送者邮箱
if MyUtil_SMTP_Msg_SetInfo(1,1,“xxx@xx.com”)<0 then
MessageBox(“info”,“发送者邮箱有误”)
end if

//发送者名称
if MyUtil_SMTP_Msg_SetInfo(1,2,“XX”)<0 then
MessageBox(gs_title,“发送者名称有误”)
end if

//接收邮箱
string ls_recvmail
ls_recvmail = “xxx@xx.com”
if MyUtil_SMTP_Msg_SetInfo(2,1,ls_recvmail)<0 then
MessageBox(“info”,“接收者邮箱有误”)
end if

//邮件标题
string ls_title
ls_title = “测试邮件标题!”
if MyUtil_SMTP_Msg_SetInfo(3,1,“测试测试”)<0 then
MessageBox(“info”,“填写标题失败”)
end if

//正文
if MyUtil_SMTP_Msg_SetInfo(5,1,“这是邮件的正文!”)<0 then
MessageBox(“info”,“填写正文失败”)
end if
//正文换行
if MyUtil_SMTP_Msg_SetInfo(5,1,“这是邮件的正文!”)<0 then
MessageBox(“info”,“填写正文失败”)
end if

//附件
if MyUtil_SMTP_Msg_SetInfo(6,1,“C:\Users\Administrator\Desktop\测试发送.xlsx”)<0 then
MessageBox(“info”,“附件新增失败”)
end if

//if MyUtil_SMTP_Connect(host,port,uid,pwd)<0 then
//messageBox(“info”,“connect Failed”)
//end if
//连接邮箱
if MyUtil_SMTP_Connect(host,port,uid,pwd)<0 then
messageBox(“info”,“连接失败”)
end if

if MyUtil_SMTP_Msg_Send()<0 then
MessageBox(gs_title,“发送失败”)
ELSE
Messagebox(gs_title,“发送成功!”)
end if

if MyUtil_SMTP_Disconnect()<0 then
MessageBox(“info”,“切断连接失败”)
end if

最后接收者的邮箱会接收到你发送的信息啦!!!

  • 5
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值