AHK:发送电子邮件问题

AHK: Sending Email Issue

我使用下面的代码通过 AHK 发送电子邮件。当我在主题和邮件正文中使用文字字符串时,它会起作用。但是当我尝试使用 %variable% 时,收到的结果电子邮件正文为空白 subject/message。

Order := 
Order = %Order% `n FAX MESSAGE
Order = %Order% `n
Order = %Order% `n Sent: %DateString% %TimeString%

pmsg            := ComObjCreate("CDO.Message")
pmsg.From       := """Lens Shapers"" <fax@l******s.com>"
pmsg.To         := "k*******r@gmail.com"
pmsg.BCC        := "" 
pmsg.CC         := "" 
pmsg.Subject    := "Lenses are Ready" **;THIS SUBJECT IS TRANSMITTED GOOD**
pmsg.TextBody   := %Order% **;THIS MESSAGE BODY IS BLANK WHEN EMAIL IS RECEIVED**
sAttach         := "" 

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 := "k*****f@l******s.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()

Loop, Parse, sAttach, |, %A_Space%%A_Tab%
  pmsg.AddAttachment(A_LoopField)
pmsg.Send()

它应该可以工作,但是当您在表达式中使用变量时,您不使用 %,而当您使用“:=”时,它是表达式的赋值.所以尝试:

pmsg.TextBody   := Order

因为这应该有效。如果您还需要文本元素,则需要在文字周围使用引号和点连接:

pmsg.TextBody   := "Order: " . Order . "`n`n"  ;  also follows with 2 new lines

Hth,