VisualBasic使用CDO发送SSL加密邮件
|
admin
2017年10月21日 18:2
本文热度 5817
|
首先,在工程里引用一个COM:Microsoft CDO for Windows 2000 Library
接着他应该会自动imports俩组件,如果没有的话你自己写:
- Imports CDO
- Imports ADODB
Imports CDO
Imports ADODB
代码:
- Private Sub SendTestCDOMessage()
- Dim cdoObj As Object
- cdoObj = CreateObject("cdo.Message")
-
-
-
-
-
-
-
- cdoObj.Configuration.Fields.item _
- ("http://schemas.microsoft.com/cdo/configuration/sendusing") _
- = CDO.CdoSendUsing.cdoSendUsingPort
-
-
- cdoObj.Configuration.Fields.item _
- ("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
- = "smtp.163.com"
-
-
- cdoObj.Configuration.Fields.item _
- ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
- = 465
-
-
- cdoObj.Configuration.Fields.item _
- ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") _
- = CDO.CdoProtocolsAuthentication.cdoBasic
-
-
-
- cdoObj.Configuration.Fields.item _
- ("http://schemas.microsoft.com/cdo/configuration/sendusername") _
- = "bbb@163.com"
- cdoObj.Configuration.Fields.item _
- ("http://schemas.microsoft.com/cdo/configuration/sendpassword") _
- = "password"
- cdoObj.Configuration.Fields.item _
- ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") _
- = "true"
-
-
-
- cdoObj.Configuration.Fields.Update()
-
-
-
- cdoObj.AddAttachment("C:\\1010.txt", "", "")
-
-
-
- cdoObj.To = "aaa@qq.com"
- cdoObj.From = "bbb@163.com"
- cdoObj.Subject = "cdo Test"
- cdoObj.TextBody = "Send Email from vb.net using cdo"
-
-
-
- cdoObj.Send()
-
-
- cdoObj = Nothing
- MsgBox("Done.")
- End Sub
该文章在 2017/10/21 18:02:50 编辑过