So I included the code below. This code is copied from Pulsover's Macro creator, which it works pretty well when used within that program.
Two questions:
1) Code runs in autohotkey but it sends the email 21 times. Im not seeing what would cause this...It consistently send 21 emails...I tried 4 times. (Sending email from gmail account)
2) I had to comment out the "MsgObj.AddAttachment(A_LoopField)" line as it gives me the 0x800C000D error (The specific protocol is unknown)
Any help will be greatly appreciated....
UserAccount1 := {email: "[email protected]", sendpassword: "password", sendusername: "system user", sendusing: 2, smtpauthenticate: 1, smtpconnectiontimeout: 30, smtpserver: "smtp.gmail.com", smtpserverport: 465, smtpusessl: 1}
MsgBody =
Attachments = C:\TEMP\Template.xlsx
CDO(UserAccount1, "[email protected]", "Subject", MsgBody, 1, Attachments)
Return
CDO(Account, To, Subject := "", Msg := "", Html := false, Attach := "", CC := "", BCC := "")
{
MsgObj := ComObjCreate("CDO.Message")
MsgObj.From := Account.email
MsgObj.To := StrReplace(To, ",", ";")
MsgObj.BCC := StrReplace(BCC, ",", ";")
MsgObj.CC := StrReplace(CC, ",", ";")
MsgObj.Subject := Subject
If (Html)
MsgObj.HtmlBody := Msg
Else
MsgObj.TextBody := Msg
Schema := "http://schemas.microsoft.com/cdo/configuration/"
Pfld := MsgObj.Configuration.Fields
For Field, Value in Account
(Field != "email") ? Pfld.Item(Schema . Field) := Value : ""
Pfld.Update()
Attach := StrReplace(Attach, ",", ";")
Loop, Parse, Attach, ;, %A_Space%%A_Tab%
; MsgObj.AddAttachment(A_LoopField)
MsgObj.Send()
}
IELoad(Pwb)
{
While !(Pwb.busy)
Sleep, 100
While (Pwb.busy)
Sleep, 100
While !(Pwb.document.Readystate = "Complete")
Sleep, 100
}
How does this code send the same email 21 times!?!!
-
- Posts: 16
- Joined: 04 Jul 2017, 19:49
Re: How does this code send the same email 21 times!?!!
Let's guess. You've 'disabled' to add the attachment. Instead you're looping the send command (bc it became the line that is assigned to the loop). Simply 'disable' the loop(line) as well and it should work. Good luck
-
- Posts: 16
- Joined: 04 Jul 2017, 19:49
Re: How does this code send the same email 21 times!?!!
@BoBo
Thanks that will explain the looping...Still no sure where 21x comes into play. I never set a variable. However I disabled that line as it always had an error on that line. You have any suggestions with that?
Thanks that will explain the looping...Still no sure where 21x comes into play. I never set a variable. However I disabled that line as it always had an error on that line. You have any suggestions with that?
Re: How does this code send the same email 21 times!?!!
The 21 comes from the number of letters in attachment.
Loop, Parse, Attach is looping through every letter.
Code: Select all
MsgBox, % StrLen("C:\TEMP\Template.xlsx")
Please excuse my spelling I am dyslexic.
Who is online
Users browsing this forum: tiska and 103 guests