msg.Priority = 3 ' '邮件的紧急程序,1 为最快,5 为最慢。 3 为默认值,表示中等
msg.ContentTransferEncoding = "base64"
If txtFileName.Text <> "" Then '附件
If Dir(txtFileName.Text) <> "" Then
contentId = msg.AddAttachment(txtFileName.Text, True) '
End If
End If
If msg.Send("smtp.163.com") Then 'msg.Send(txtusername.Text & ":" & txtpassword.Text & "@" & txthostname.Text)
MsgBox "OK!!"
End If
msg.Close
Set msg = Nothing
If Len(Trim(txtSendAlso.Text)) > 0 Then
strarr = Split(txtSendAlso.Text, ";")
For intx = 0 To UBound(strarr)
msg.AddRecipientCC strarr(intx)
Next
End If
msg.Priority = 3
msg.ContentTransferEncoding = "base64"
If txtFileName.Text <> "" Then'附件
If Dir(txtFileName.Text) <> "" Then
contentId = msg.AddAttachment(txtFileName.Text, True) '
End If
End If
msg.Subject = txtSubject.Text'主题
msg.Body = Text1.Text
msg.MailServerUserName = txtusername.Text'用户名
msg.MailServerPassWord = txtpassword.Text'密码
If msg.Send(txthostname.Text & ":" & txtPort.Text) Then 'msg.Send(txtusername.Text & ":" & txtpassword.Text & "@" & txthostname.Text)
MsgBox "OK!!"
End If
msg.Close
Set msg = Nothing
Exit Sub
Dim strSubject, strTxtBody, strTo, strCC, strBCC, strAttachFile
Dim MailServer, MailPort
MailServer = "MAILSERVER"
MailPort = 25 '...probably
strAttachFile = "c:\Attach.pdf" 'you can comment out the "AddAttachment
strSubject = "Subject" 'if you dont wish to use
strTxtBody = "Body"
strTo = "friend@earth.com;secondfriend@earth.com"
Set objCDO = CreateObject("CDO.Message")
Set objCDOConfig = CreateObject("CDO.Configuration")
Set objFields = objCDOConfig.Fields
With objFields
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = MailServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = MailPort
.Item("http://schemas.microsoft.com/cdo/configuration/SendUsing") = 2
.Update
End With
With objCDO
.Configuration = objCDOConfig
.To = strTo
.CC = strCC
.BCC = strBCC
.From = "me@home.com"
.Subject = strSubject
.HTMLBody = strTxtBody
'.AddAttachment (strAttachFile)
.Send
End With
Set objFields = Nothing
Set objCDOConfig = Nothing
Set objCDO = Nothing