2017-10-29 151 views
2

我用這個基本的VBScript代碼發送了電子郵件,有人和它的作品很好,但我想確認郵件已收到。 有沒有辦法做到這一點? 我用它來發送郵件的代碼是:的VBScript - 最佳的方式來確認郵件已收到

Dim objMessage 'object mail 

Set objMessage = CreateObject("CDO.Message") 
objMessage.BodyPart.Charset = "utf-8" 
objMessage.Subject = subjectStr 
objMessage.From = "To someone" 
objMessage.To = toWhoStr 
objMessage.TextBody = contentStr 
objMessage.AddAttachment AttachmentFile 

'==This section provides the configuration information for the remote SMTP server. 
objMessage.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 

'Name or IP of Remote SMTP Server 
objMessage.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "ip smtp server" 

'Type of authentication, NONE, Basic (Base64 encoded), NTLM 
objMessage.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1'cdoBasic 


'Server port (typically 25) 
objMessage.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587 

'Use SSL for the connection (False or True) 
objMessage.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = false 

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server) 
objMessage.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 

objMessage.Configuration.Fields.Update 

'==End remote SMTP server configuration section== 

objMessage.Send 

Set ObjMessage = Nothing 

UPDATE更新我的代碼,現在我得到通知,一些電子郵件。

Const CDO_SUCCESS = 4 ' sends delivery receipt if succesfull 
Const CDO_FAIL = 2 ' sends delivery receipt if fails 
Const CDO_DELAY = 8 ' sends delivery receipt if delayed 
Const CDO_SUCCESS_FAIL_DELAY = 14 ' sends delivery receipt always 

Dim objMessage 'object mail 
Dim iConf 
Dim Flds 
    Set objMessage = CreateObject("CDO.Message") 

    set iconf = createobject("cdo.configuration") 
    Set Flds = iConf.Fields 
    With Flds 
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "ip smtp server" 
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1'cdoBasic 
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username" 
    .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password" 
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True 
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 
    .Update 
    End With 
    '==End remote SMTP server configuration section== 

    With objMessage 
     .BodyPart.Charset = "utf-8" 
     Set .Configuration = iConf 
     .To = toWhoStr 
     .From = "from who" 
     .Subject = "BLA BLA BLA" 
     .TextBody = "PING PONG" 
     .fields("urn:schemas:mailheader:disposition-notification-to") = "email to notification" 
     .fields("urn:schemas:mailheader:return-receipt-to") = "email to notification" 
     .DSNOptions = 14 
     .fields.update 
     .Send 
    End With 
    Set ObjMessage = Nothing 

有了這個代碼時發送給他的郵件用戶打開郵件,並嘗試關閉然後如果他想通知他簽收郵件是詢問郵件打開彈出窗口。

我沒有找到一種方法,它是自動發送通知。

回答

相關問題