[英]Save email to draft folder in Outlook
我已经有发送电子邮件的代码,但是我不希望发送它,而只希望将其保存在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
采用:
.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
CDO不提供任何Save
方法。 而且,这是一项非常古老的技术,如今已不再使用。 相反,我建议使用提供Save方法的Outlook对象模型。 您可能会发现以下文章有帮助:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.