通过VB6发送电子邮件
发布时间:2020-12-17 00:25:39  所属栏目:大数据  来源:网络整理 
            导读:我想知道是否有办法通过VB6发送电子邮件(SMTP).我有一个应用程序,只需要在用户完成后发送一个简单的电子邮件,让组知道应用程序已处理.有没有办法做到这一点? 是的 – 取决于您使用的 Windows版本.假设其中一个版本 – CDO.Message工作得很好. Sub SendMessa
                
                
                
            | 
                         
 我想知道是否有办法通过VB6发送电子邮件(SMTP).我有一个应用程序,只需要在用户完成后发送一个简单的电子邮件,让组知道应用程序已处理.有没有办法做到这一点?
 
 是的 – 取决于您使用的 
 Windows版本.假设其中一个版本 – CDO.Message工作得很好. 
  
  
                          Sub SendMessage(MailFrom,MailTo,Subject,Message)
    Dim ObjSendMail
    Set ObjSendMail = CreateObject("CDO.Message")
    'This section provides the configuration information for the remote SMTP server.
    With ObjSendMail.Configuration.Fields
    .Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smpt server Address"
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    ' If your server requires outgoing authentication uncomment the lines below and use a valid email address and password.
'    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
'    .Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = MailFrom
'    .Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = yourpassword
    .Update
    End With
    'End remote SMTP server configuration section==
    ObjSendMail.To = MailTo
    ObjSendMail.Subject = Subject
    ObjSendMail.From = MailFrom
    ' we are sending a html email.. simply switch the comments around to send a text email instead
    ObjSendMail.HTMLBody = Message
    'ObjSendMail.TextBody = Message
    ObjSendMail.Send
    Set ObjSendMail = Nothing
End Sub
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!  | 
                  
