pb下调用mymail.dll自动发送邮件 经验谈

pb下调mymail的例子很多,遇到的问题在很多坛子上都有回答,几乎都是同一个版本,翻了N个网页,看了真是痛苦,很多都没有回答到点子上,下面是我参考csdn帖子上的内容,理出的正确用法。 
申明Local External Functions: function int MyUtil_SMTP_Connect(string host,int port,string UserId,string PassWord) library "MyMail.dll" function int MyUtil_SMTP_Disconnect() library "MyMail.dll" function int MyUtil_SMTP_Msg_Init() library "MyMail.dll" function int MyUtil_SMTP_Msg_SetInfo(int i_type,int i_sub_type,string as_text) library "MyMail.dll" function int MyUtil_SMTP_Msg_Send() library "MyMail.dll" 发送代码: //使用例程: string ls_host,ls_user,ls_pwd,ls_mail_to,ls_mail_cc,& ls_subject,ls_text,ls_mail_fr,ls_attach int li_port,li_ret ls_host=trim(sle_host.text) //服务器名 ls_user=trim(sle_user.text) //发件人登陆发件服务器时的用户名 ls_pwd=trim(sle_password.text) //发件人登陆发件服务器时的密码 li_port=integer(sle_port.text) //发送服务器的smtp端口号,没改的话一般是25 ls_mail_to=trim(sle_mail_to.text)//接收人email地址 ls_mail_cc=trim(sle_mail_cc.text)//抄送,好像有点问题,我没有成功 ls_subject=sle_subject.text //主题 ls_mail_fr=trim(sle_mail_fr.text) //发件人 ls_text=mle_text.text //正文 ls_attach=trim(sle_attach.text) //附件,多个的话要分开 setpointer(hourglass!) //邮件初始化: if MyUtil_SMTP_Msg_Init()<0 then MessageBox("info","初始化失败!!!"); end if if MyUtil_SMTP_Msg_SetInfo(1,1,ls_mail_fr)<0 then MessageBox("info","设置发送者信息出错!!!") end if if MyUtil_SMTP_Msg_SetInfo(1,2,ls_user)<0 then MessageBox("info","设置发送者名称出错!!!") end if if MyUtil_SMTP_Msg_SetInfo(2,1,ls_mail_to)<0 then MessageBox("info","设置接收者地址出错!!!") end if //if MyUtil_SMTP_Msg_SetInfo(2,1,ls_mail_cc)<0 then //MessageBox("info","设置接收者地址出错!!!") //end if if MyUtil_SMTP_Msg_SetInfo(3,1,ls_subject)<0 then MessageBox("info","设置主题出错!!!") end if if MyUtil_SMTP_Msg_SetInfo(5,1,ls_text)<0 then MessageBox("info","设置正文失败!!!") end if if MyUtil_SMTP_Msg_SetInfo(6,1,ls_attach)<0 then MessageBox("info","设置附件名称出错!!!") end if if MyUtil_SMTP_Connect(ls_host,li_port,ls_user,ls_pwd)<0 then messageBox("info","连接失败!") end if if MyUtil_SMTP_Msg_Send()<0 then MessageBox("info","发送失败!") else Messagebox('Info','发送成功!') FileDelete ( ls_attach ) end if if MyUtil_SMTP_Disconnect()<0 then MessageBox("info","断开失败!!!") end if setpointer(arrow!)
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值