Private Sub Form_Load()
Me.Visible = False
Dim objEmail As Object
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "原邮箱"
objEmail.To = "目的邮箱"
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_sendMailTextl 函数原型:
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 下载
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)