AutoHotkey Community

It is currently May 27th, 2012, 6:22 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 44 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject:
PostPosted: December 9th, 2010, 8:12 am 
Offline

Joined: September 15th, 2006, 10:25 am
Posts: 567
could you post your entire relevant code, so that i can try it on my machine.
also kindly mention your OS, 32/64bit and A_AHKVersion


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2010, 9:52 am 
Offline

Joined: February 22nd, 2009, 7:24 pm
Posts: 21
Location: Dallas TX
Sure,

Architecture: AMD Phenom 9850 Quad @ 2.51GHz
OS: Windows XP 64bit professional SP3 (also tested on xp32 sp3 intel chip)

A_AHKVERSION: 10.48.05.L61 (AHK_L)

Code:
FromAddress := "noreply@gmail.com"
ToAddress := "ToAddress@gmail.com"
MessageSubject := "MAPI TEST"
MessageBody := "This is a test of the MAPI hooked batch sender"
AttachmentPath := "c:\TEST.txt|c:\TEST.ico" ; can add multiple attachments, the delimiter is |

ol := ComObjCreate("Outlook.Application")
ns := ol.getNamespace("MAPI")
ns.logon("","",true,false)
newMail := ol.CreateItem(0)
newMail.Subject := MessageSubject
newMail.Body := MessageBody
MessageAttach := newMail.Attachments
Loop, Parse, AttachmentPath, |, %A_Space%%A_Tab%
MessageAttach.Add(A_LoopField)

; validate the recipient, just in case...
myRecipient := ns.CreateRecipient(ToAddress)
myRecipient.Resolve
If Not myRecipient.Resolved
MsgBox "unknown recipient"
Else
{
newMail.Recipients.Add(myRecipient)
newMail.Sender := FromAddress
newMail.Send
MsgBox mail sent!
}
Return

_________________
"lol, i made this thing, but it didn't work... so I read the forums and now it does!"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2010, 12:18 pm 
Offline

Joined: September 15th, 2006, 10:25 am
Posts: 567
The code you sent me is working perfectly on my machine. What version of Outlook are you using?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2010, 12:23 pm 
Offline

Joined: February 22nd, 2009, 7:24 pm
Posts: 21
Location: Dallas TX
OH! derp...
I have Outlook 2007 (12.0.4518.1014) and I was using hooks for 2010... thanks I never would have thought of that :D

Yeah that's what happens when I sleep between writing a script

_________________
"lol, i made this thing, but it didn't work... so I read the forums and now it does!"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 7th, 2011, 7:41 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
It seems now that JSON support is in it might be better to transition the attachment process to an array that can be traversed in a for-loop:

Code:
sAttach      :=   ["Path_Of_Attachment"]   ; can add multiple attachments to array e.g. ["Path_Of_Attachment1","Path_Of_Attachment2","Path_Of_Attachment3"]

. . .

For each, item in sAttach
   pmsg.AddAttachment(item)

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: December 20th, 2011, 6:15 pm 
Hi @ all I have tested every code and tried to fix it for me for example in the first code I had 2 Errors and marked them in the code can someone help?
Code:
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><br /><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) <---- here
pmsg.Send() <---- and here

first Error was " the specified protocol is unkown"
the second after i fixed the first was "The message couldn´t be send to the SMTP-Server. The Serveranswer was "not available"
could it be that my SMTP-Server is wrong, because i don´t have gmail and tried to use it with gmx?
I only show that code because it was the one with only 2 Errors, i hope someone will answer and that the Topic isn´t too old.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 20th, 2011, 6:38 pm 
I have finally found the mistake and now get an e-mail, but in the e-mail are not the files i have attached.
I always only get a noname File with 0 Byte i can download.
thx for any help^^


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 3rd, 2012, 1:43 pm 
Offline

Joined: June 7th, 2007, 1:33 pm
Posts: 1019
I want to assign some global hotkeys to these actions:

- send specific email body with specific subject to specific receipient
- the same as above, but opening a GUI to specify email body text
- the same as the first, but opening a GUI to specify attachment
etc

any hint?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 12th, 2012, 10:14 am 
Offline

Joined: April 14th, 2011, 2:21 am
Posts: 30
Hi all,
Is there any way to check if the email has been sent or not?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 26th, 2012, 7:56 am 
Offline

Joined: April 14th, 2011, 2:21 am
Posts: 30
zeus19 wrote:
Hi all,
Is there any way to check if the email has been sent or not?


Can somebody help me out with the question above?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 27th, 2012, 2:47 pm 
Offline

Joined: October 4th, 2006, 2:15 am
Posts: 250
Location: Louisville, KY
I don't think so. I believe the assumption is that if your mail server accepts the message - no errors while sending it to the server - then it's on it's way. Of course mail servers may queue messages up, delaying delivery, but I don't think there's a standard way to query a mail server to see if it's actually sent it's message yet.

Even if you could query the server, it wouldn't tell you whether the message has actually been received yet anyway since mail gets forwarded through many mail servers on the way to it's destination. The best you can do is to put a return receipt on the message, which of course itself isn't very reliable.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 1st, 2012, 9:52 am 
Offline

Joined: August 15th, 2009, 7:20 am
Posts: 308
I'm getting the following error message:

Quote:
---------------------------
email com.ahk
---------------------------
Error: 0x80040213 -
Source: CDO.Message.1
Description: The transport failed to connect to the server.


HelpFile: (null)
HelpContext: 0

Specifically: Send

Line#
029: schema := "http://schemas.microsoft.com/cdo/configuration/"
032: pfld := pmsg.Configuration.Fields
034: For field,value in fields
035: pfld.Item(schema . field) := value
036: pfld.Update()
038: Loop,Parse,sAttach,|,%A_Space%%A_Tab%
039: pmsg.AddAttachment(A_LoopField)
---> 040: pmsg.Send()
041: Exit
042: Exit
042: Exit

Continue running the script?
---------------------------
Yes No
---------------------------


I've tested the smtp server using Thunderbird and it worked. Can anyone tell me why I might be seeing this message and suggest solutions. Thanks.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 1st, 2012, 1:42 pm 
Offline

Joined: October 4th, 2006, 2:15 am
Posts: 250
Location: Louisville, KY
Is it a firewall issue perhaps?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 1st, 2012, 10:53 pm 
Offline

Joined: August 15th, 2009, 7:20 am
Posts: 308
wtg wrote:
Is it a firewall issue perhaps?


Thanks, I don't think so. I'm using Windows Firewall and it isn't blocking outbound connections.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 44 posts ]  Go to page Previous  1, 2, 3

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group