Public Function ToMail(TempTxt As String) As Boolean
Dim NameS As String
Dim Email As Object
ToMail = False
On Error GoTo Err1
NameS = "http://schemas.microsoft.com/cdo/configuration/"
Set Email = CreateObject("CDO.Message")
Email.From = "[email protected]" '你的地址
Email.To = "[email protected]"'对方地址
Email.Subject = "邮件标题!"
Email.Textbody = "邮件内容"
Email.Configuration.Fields.Item(NameS & "sendusing") = 2
Email.Configuration.Fields.Item(NameS & "smtpserver") = "smtp.xxx.xxx"
Email.Configuration.Fields.Item(NameS & "smtpserverport") = 25
Email.Configuration.Fields.Item(NameS & "smtpauthenticate") = 1
Email.Configuration.Fields.Item(NameS & "sendusername") = "邮件用户名"
Email.Configuration.Fields.Item(NameS & "sendpassword") = "邮件密码"
Email.Configuration.Fields.Update
DoEvents
Email.Send
Set Email = Nothing
ToMail = True
Exit Function
Err1:
ToMail = False
End Function
'-----------------------------------------以下接收邮件-----------------
Private Sub Command1_Click()
Dim strSubject As String
Dim pop3 As New jmail.pop3
Dim mailMessage As New jmail.Message
pop3.Connect "用户名", "密码", "pop3.126.com"
pop3.DownloadMessages
If pop3.Count > 0 Then
Dim i As Integer, j As Integer, judge As Integer, p As Integer
For i = 1 To pop3.Count
strSubject = pop3.Messages.Item(i).Subject '主题
If strSubject = "测试一下" Then
MsgBox "测试通过"
ElseIf strSubject = "测试一下警告" Then
MsgBox "请使用正规渠道软件"
ElseIf strSubject = "测试一下删除" Then
MsgBox "删除注册信息"
End If
Next i
End If
pop3.Disconnect
err:
End Sub