使用VBscript发送附件时,为附件指定名称

时间:2015-01-14 20:16:52

标签: vbscript cdo.message

set cdoConfig = CreateObject("CDO.Configuration")
with cdoConfig.Fields
  .Item(cdoSendUsingMethod) = cdoSendUsingPort
  .Item(cdoSMTPServer) = "localhost"
  .Item(cdoSMTPAuthenticate) = 1
  .Item(cdoSendUsername) = "contact@example.com"
  .Item(cdoSendPassword) = "password"
  .Update
end with
set cdoMessage = CreateObject("CDO.Message")
with cdomessage
set .Configuration = cdoConfig
  .From = "contact@example.com"
  .To = email
  .Subject = subject
  .HTMLBody = message
  .AddAttachment "c:/i/report.pdf"
  .Send
end with
set cdomessage = nothing
set cdoconfig = nothing

所有内容都会发送,但收件人会收到消息“#34; Untitled Attachment 000X.pdf"

如何为附件命名?

1 个答案:

答案 0 :(得分:1)

我有类似的东西。但从未尝试过。

'With cdomessage

.AddAttachment "c:/i/report.pdf"
.Attachments(1).Fields.Item("urn:schemas:mailheader:content-disposition") ="attachment;filename=" & NEWNAME
.Attachments(1).Fields.Update

'End With