如何实现把程序运行结果自动发送邮件?

如何实现把程序运行结果自动发送邮件?,第1张

用我这个,根据发件邮箱,更改下面的服务器,原邮箱,目的邮箱,然后将程序快捷方式放在启动里就可实现开机运行,不要做非法的事

Private Sub Form_Load()

Me.Visible = False

Dim objEmail As Object

Set objEmail = CreateObject("CDO.Message")

objEmail.From = "原邮箱"

objEmail.To = "目的邮箱"

objEmail.Subject = "邮件标题"

objEmail.Textbody = "邮件正文 "

objEmail.AddAttachment App.Path &"\abc.ini" '附件内容,不要可删掉

objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.163.com" '发信服务器,假设为163邮箱

objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = " 发信的邮箱名"

objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "发信的邮箱密码"

objEmail.Configuration.Fields.Update

objEmail.Send

End Sub

如果邮件的内容已经遍及好了,可以使用系统自带的outlook 邮件客户端,将编辑好的邮件存储为eml文件,然后通过控制面板中的任务与计划执行定时启动outlook并且发送文件.eml的命令。即可执行自动发送。

3.70 icePub_sendMailText

l 函数原型:

int WINAPI icePub_sendMailText(char *strUsername,char *strPassword,char *strSmtpServer,char *sendMail,char *toMailList,char *strSubject,char *strText)

输入:strUsername smtp用户名

strPassword 用户密码

strSmtpServer smtp服务器

sendMail 发件人邮箱地址

toMailList 收件人邮箱地址

strSubject 标题

strText 文本内容

输出:

l VC连接Lib方式声明

__declspec(dllexport)

int WINAPI icePub_sendMailText(char *strUsername,char *strPassword,char *strSmtpServer,char *sendMail,char *toMailList,char *strSubject,char *strText)

l 动态调用例程

VC sample 代码:

{

typedef int (WINAPI ICEPUB_SENDMAILTEXT)(char *strUsername,char *strPassword,char *strSmtpServer,char *sendMail,char *toMailList,char *strSubject,char *strText)

ICEPUB_SENDMAILTEXT *icePub_sendMailText = 0

HINSTANCE hDLLDrv = LoadLibrary("icePubDll.dll")

if(hDLLDrv)

{

icePub_sendMailText = (ICEPUB_SENDMAILTEXT *)GetProcAddress(hDLLDrv, "icePub_sendMailText")

}

if(icePub_sendMailText)

icePub_sendMailText("ahuinuli","112233","smtp.tom.com","[email protected]","[email protected]","标题:还好么?","文本:扉心祈梦,梦语问春天。")

if(hDLLDrv)

FreeLibrary(hDLLDrv)

}

VB sample 代码:

Private Declare Function icePub_sendMailText Lib "icePubDll.dll" (ByVal strusername As String, ByVal strPassword As String, ByVal strSmtpServer As String, ByVal sendMail As String, ByVal toMailList As String, ByVal strSubject As String, ByVal strText As String) As Integer

Dim a2 As Integer

a2 = icePub_sendMailText("ahuinuli", "112233", "smtp.tom.com", "[email protected]", "[email protected]", "标题:没事。", "文本:含悲谈笑,笑说人世间。")

http://dl.icese.net/dev.php?f=icePubDll.rar 下载


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/8015139.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-12
下一篇 2023-04-12

发表评论

登录后才能评论

评论列表(0条)

保存