我在Windows 7中使用了以下代码,一切正常,但是当我在Windows 10上使用相同的代码时,它停止工作并向我发现下面发现的错误;
以前在Windows 7中为我工作的代码:
pmsg := ComObjCreate("CDO.Message")
pmsg.From := """John Agius"" <something@gmail.com>"
pmsg.To := "somtehting@gmail.com"
pmsg.BCC := ""
pmsg.CC := ""
pmsg.Subject := "Message / Note"
pmsg.TextBody :=emailtosomeone
fields := Object()
fields.smtpserver := "smtp.gmail.com" ; specify your SMTP server
fields.smtpserverport := 465 ; 25
fields.smtpusessl := True ; False
fields.sendusing := 2 ; cdoSendUsingPort
fields.smtpauthenticate := 1 ; cdoBasic
fields.sendusername := "user@gmail.com"
fields.sendpassword := "password"
fields.smtpconnectiontimeout := 60
schema := "http://schemas.microsoft.com/cdo/configuration/"
pfld := pmsg.Configuration.Fields
For field,value in fields
pfld.Item(schema . field) := value
pfld.Update()
pmsg.Send()
在Windows 10中,它给出了以下错误;
错误:0x800CCE05 资料来源:CDO.Message.1 说明:此消息中未找到请求的正文部分 HelpFile(Null) HelpContext:0
具体来自; ; bla bla bla工作代码 -------&GT; pmsg.From:=“”“John Agius”“”
有人可以帮帮我吗?我真的需要这个来为我的工作而努力。由于
John Agius
答案 0 :(得分:1)
嗯,错误是在谈论遗漏的身体。因此,您可能错过了电子邮件中的实际短信(TextBody或HtmlBody)。是否定义了变量emailtosomeone? 试试这段代码:
pmsg := ComObjCreate("CDO.Message")
pmsg.From := """AHKUser"" <...@gmail.com>"
pmsg.To := "anybody@somewhere.com"
pmsg.BCC := "" ; Blind Carbon Copy, Invisable for all, same syntax as CC
pmsg.CC := "Somebody@somewhere.com, Other-somebody@somewhere.com"
pmsg.Subject := "Message_Subject"
;You can use either Text or HTML body like
pmsg.TextBody := "Message_Body"
;OR
;pmsg.HtmlBody := "<html><head><title>Hello</title></head><body><h2>Hello</h2><p>Testing!</p></body></html>"
sAttach := "Path_Of_Attachment" ; can add multiple attachments, the delimiter is |
fields := Object()
fields.smtpserver := "smtp.gmail.com" ; specify your SMTP server
fields.smtpserverport := 465 ; 25
fields.smtpusessl := True ; False
fields.sendusing := 2 ; cdoSendUsingPort
fields.smtpauthenticate := 1 ; cdoBasic
fields.sendusername := "...@gmail.com"
fields.sendpassword := "your_password_here"
fields.smtpconnectiontimeout := 60
schema := "http://schemas.microsoft.com/cdo/configuration/"
pfld := pmsg.Configuration.Fields
For field,value in fields
pfld.Item(schema . field) := value
pfld.Update()
Loop, Parse, sAttach, |, %A_Space%%A_Tab%
pmsg.AddAttachment(A_LoopField)
pmsg.Send()
https://autohotkey.com/board/topic/60813-cdo-com-email-delivery-ahk-l/#p403177