我已经具有发送电子邮件的代码,但是我不希望发送它,而只是希望将其保存在Outlook的草稿文件夹中。
我尝试添加.Close
函数,但这种方法不起作用。有想法吗?
Dim iCfg As CDO.Configuration
Dim iMsg As CDO.message
Dim EmailAddr As String
Dim wsEmail As Worksheet
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Forecast")
Set wsEmail = ThisWorkbook.Worksheets("Recepient")
Set iCfg = New CDO.Configuration
With iCfg
.Fields(cdoSMTPServer) = "XXX"
.Fields(cdoSMTPServerPort) = 25
.Fields(cdoSendUsingMethod) = cdoSendUsingPort
.Fields(cdoSMTPConnectionTimeout) = 200
.Fields.Update
End With
Set iMsg = New CDO.message
With iMsg
Set .Configuration = iCfg
.To = Worksheets("Recepient").Cells(5, 2).Value
.cc = Worksheets("Recepient").Cells(5, 3).Value
.From = "Automated Notification <NoReplyEmail@agit.com>"
.Subject = "OPEN REQUEST " & Format(Now, "dd-mmm-yyyy")
.HTMLBody = strBodyStandard
.Close (olsave)
End With
Set iMsg = Nothing
Set iCfg = Nothing
End Sub
答案 0 :(得分:0)
使用:
.Close olSave
代替:
.Close
olSave
会将邮件保存在“草稿文件夹”中
您的代码:
With iMsg
Set .Configuration = iCfg
.To = Worksheets("Recepient").Cells(5, 2).Value
.cc = Worksheets("Recepient").Cells(5, 3).Value
.From = "Automated Notification <NoReplyEmail@agit.com>"
.Subject = "OPEN REQUEST " & Format(Now, "dd-mmm-yyyy")
.HTMLBody = strBodyStandard
.Close olSave
'.Send
End With
答案 1 :(得分:0)
CDO不提供任何Save
方法。而且,这是一项非常古老的技术,如今已不再使用。相反,我建议使用提供Save方法的Outlook对象模型。您可能会发现以下文章很有帮助: