AutoHotkey Community

It is currently May 27th, 2012, 12:26 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 199 posts ]  Go to page Previous  1 ... 10, 11, 12, 13, 14  Next
Author Message
 Post subject:
PostPosted: February 16th, 2011, 5:33 am 
P.S.

It worked :wink:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 11th, 2011, 12:40 am 
Offline

Joined: November 22nd, 2010, 5:10 pm
Posts: 9
Location: Indianapolis, Indiana
I was running into some confusing issues when trying to use shajul's and infogulch's code using the built in COM for AHK_L. I barely understand COM or AHK_L for that matter, but between their two examples I found the code that worked for me. This might save my fellow noobs some time too.

This line:
Code:
  pmsg.AddAttachment := A_LoopField


should be:
Code:
  pmsg.AddAttachment(A_LoopField)


Code updated below. (AHK_L)

shajul wrote:

Code:
sFrom     := "...@gmail.com"
sTo       := "anybody@somewhere.com"
sSubject  := "Message_Subject"
sBody     := "Message_Body"
sAttach   := "Path_Of_Attachment" ; can add multiple attachments, the delimiter is |

sServer   := "smtp.gmail.com" ; specify your SMTP server
nPort     := 465 ; 25
bTLS      := True ; False
nSend     := 2   ; cdoSendUsingPort
nAuth     := 1   ; cdoBasic
sUsername := "...@gmail.com"
sPassword := "your_password_here"

pmsg :=   ComObjCreate("CDO.Message")
pcfg :=   pmsg.Configuration
pfld :=   pcfg.Fields

pfld.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") := nSend
pfld.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") := 60
pfld.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") := sServer
pfld.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") := nPort
pfld.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") := bTLS
pfld.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") := nAuth
pfld.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") := sUsername
pfld.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") := sPassword
pfld.Update()

pmsg.From := sFrom
pmsg.To := sTo
pmsg.Subject := sSubject
pmsg.TextBody := sBody
Loop, Parse, sAttach, |, %A_Space%%A_Tab%
    pmsg.AddAttachment(A_LoopField)
pmsg.Send()


If you intend to use it as a function, Infogulch's code needs a small change too.

before:
Code:
pmsg := COM_CreateObject("CDO.Message")

after:
Code:
pmsg := ComObjCreate("CDO.Message")


Code updated below. (AHK_L)

infogulch wrote:
Code:
Email("from@email.com", "receipient@emails.com", "Message_Subject", "Message_Text", "username", "password", "sbserver.domain.local")

Email(pFrom, pTo, pSubject, pBody, pUsername, pPassword, pServer, pPort=25, pUseSSL=False, pAttach="", isHtml=False) {
   pmsg := ComObjCreate("CDO.Message")
   
   base := "http://schemas.microsoft.com/cdo/configuration/"
   pfld := pmsg.Configuration.Fields
   pfld.Item(base "sendusing").value             := 2 ; 2=cdoSendUsingPort (requires: smtpserverport, smtpauthenticate, smtpserver)
   pfld.Item(base "smtpconnectiontimeout").value := 60
   pfld.Item(base "smtpusessl").value            := pUseSSL
   pfld.Item(base "smtpauthenticate").value      := 1 ; 1=cdoBasic
   pfld.Item(base "smtpserver").value            := pServer
   pfld.Item(base "smtpserverport").value        := pPort
   pfld.Item(base "sendusername").value          := pUsername
   pfld.Item(base "sendpassword").value          := pPassword
   pfld.Update()

   pmsg.From     := pFrom
   pmsg.To       := pTo
   pmsg.Subject  := pSubject

   if isHtml
      pmsg.HtmlBody := pBody
   else
      pmsg.TextBody := pBody
   
   Loop, Parse, pAttach, |, %A_Space%%A_Tab%
      pmsg.AddAttachment(A_LoopField)
   
   pmsg.Send()

   pfld := ""
   pmsg := ""
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject: SendMailMSCDO function
PostPosted: October 1st, 2011, 4:47 pm 
Offline

Joined: October 28th, 2008, 1:30 am
Posts: 14
Update #3: Emails go out perfectly using port 465 & 25. When I try to use port 587 for GMail, I get the following error:

COM Error Notification :
Function Name: “Send”
ERROR: (0x80040213)
PROG: CDO.Message.1
DESC: The transport failed to connect to the server.

HELP: ,0

Will Continue?

In my case, choosing to continue does not result in sending a successful email. Thanks in advance for any help. I don't think my ISP would block port 587 while they are not blocking 25 & 465. Anyone know of any client side port detectives that will give both incoming & outgoing port status?

---------------------------------------------------------------

Update#2: I'm doing OK with just leaving out the COM_Term() function. For anyone else having the same problem, your script may serve your purpose if you just leave this function out.

---------------------------------------------------------------

UpDate #1: I found out where my script was hanging up. If I place a pause command right before the COM_Term() function, the script doesn't hang up and I can terminate it via the tray icon. When I unpause & resume the script, it is when the COM_Term() function is executing that puts my computer in the state described below. Any suggestions?

---------------------------------------------------------------

After adding CC & BCC objects, my first attempt at using Sean's original code in a function was totally successful. All the emails, with multiple recipients in different categories (To, CC, BCC), went out perfectly.

When I run the script below, I have the following problems:

The AHK tray icon representing this script won't close automatically after the script runs. It remains there indefinitely until I close it via task manager, currently the only practical method of closing it.

I can't invoke right-click options or double-click the tray icon for this script to bring up the native AHK script progress monitor. When I try to run this script again while the icon is still in the tray, I get "Could not close the previous instance of this script. Keep Waiting?"

Everything else on my computer runs fine; as stated before, the emails go out perfectly.

I'm running AHK Version 1.0.48.05 standard; Win XPSP2; ZoneAlarm Security Suite; Latest Rev of COM.ahk for AHK standard; #Include %A_ScriptDir%, #Include COM.ahk, NOT Persistent.

Thank you in advance for any guidance.



Code:
#SingleInstance force
SetTitleMatchMode, 2


;This script uses MS Collaborative Data Object library via COM/DLL calls.  Info on CC & BCC can be found in AHK forum CDO COM - Email Delivery--pages 7, etc, and http://msdn.microsoft.com/en-us/library/ms527351.aspx.  CC & BCC were easily accomplished by adding the COM_Invoke statements for those objects.  Thanks to Sean for the main code body and the Com Library.


sFrom     := "*******@gmail.com"
sTo       := "*******@gmail.com"
sCC       := "*******@gmail.com"
sBCC      := "*******@gmail.com"
sSubject  := "GNU Public License"
sBody     := "Please Read The Attachment"
sAttach   := ""

sServer   := "smtp.gmail.com" ; specify your SMTP server
nPort     := 465 ; 25
bTLS      := True ; False
sUsername := "*******"
sPassword := "*******"

nSend     := 2   ; cdoSendUsingPort
nAuth     := 1   ; cdoBasic


COM_Init()
pmsg :=   COM_CreateObject("CDO.Message")
pcfg :=   COM_Invoke(pmsg, "Configuration")
pfld :=   COM_Invoke(pcfg, "Fields")

COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendusing", nSend)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 60)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserver", sServer)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserverport", nPort)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpusessl", bTLS)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", nAuth)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendusername", sUsername)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendpassword", sPassword)
COM_Invoke(pfld, "Update")

COM_Invoke(pmsg, "From", sFrom)
COM_Invoke(pmsg, "To", sTo)
COM_Invoke(pmsg, "CC", sCC)
COM_Invoke(pmsg, "BCC", sBCC)
COM_Invoke(pmsg, "Subject", sSubject)
COM_Invoke(pmsg, "TextBody", sBody)
Loop, Parse, sAttach, |, %A_Space%%A_Tab%
COM_Invoke(pmsg, "AddAttachment", A_LoopField)
COM_Invoke(pmsg, "Send")

COM_Release(pfld)
COM_Release(pcfg)
COM_Release(pmsg)
pause
COM_Term()

#Include %A_ScriptDir%
#Include COM.ahk

_________________
Better a diamond with a flaw than a pebble without.


Last edited by LordOfTheFiles on October 4th, 2011, 3:02 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 19th, 2011, 11:05 am 
Offline

Joined: October 5th, 2011, 11:32 pm
Posts: 66
Location: Poland
I have this error

Code:
COM Error Notification :
Function Name: “Send”
ERROR: (0x80040213)
PROG: CDO.Message.1
DESC: The transport failed to connect to the server.

HELP: ,0


even with port 465 and 25
username and password have good, i have no attachment but i left "" in place where it should be directory to file.

Can anyone advice me what i am doing wrong? I am using code from 1st page.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 19th, 2011, 11:20 am 
Offline
User avatar

Joined: May 18th, 2010, 3:10 pm
Posts: 1179
Location: Sweden
musiek wrote:
I have this error

Code:
COM Error Notification :
Function Name: “Send”
ERROR: (0x80040213)
PROG: CDO.Message.1
DESC: The transport failed to connect to the server.

HELP: ,0


even with port 465 and 25
username and password have good, i have no attachment but i left "" in place where it should be directory to file.

Can anyone advice me what i am doing wrong? I am using code from 1st page.


I know some clients have had that problem when some COM function is not available on their computer. That's why I changed to a PHP solution for my apps.

_________________
~sumon Appifyer AHK Nova halted Recommended: AHK_L (Why?)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2012, 1:45 am 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
I have tried usng this interface with gmail. In general it works, but is there something that must be done after sending a mail? Because right now it will timeout if I try to run it two or more times in a row and takes a few minutes until it will work again.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2012, 4:46 pm 
There is no reliable solution for sending mail in pure Ahk yet.
This and this can error for fun.
Use mailsend which NEVER errors if you pass the right command lines.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2012, 4:54 pm 
Blat either exe or DLL.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2012, 5:01 pm 
Anonymous wrote:
Blat either exe or DLL.


Can you post a fully working script with all the parameters including attachments using blat?
The forum threads about blat are not working.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2012, 9:57 pm 
Offline

Joined: May 23rd, 2009, 4:48 am
Posts: 365
Location: north bay, california
I switched from blat exe when i first learned ahk, the went to blat dll when i figured it out, then went to this cdo com email function when i figured it out...

Never had any reliability problems with any of them, i recommend this function... Itd be easy enough to make an email composer that used any of those three (and add mailsend if recommended) by choice to test reliability with same settings/environment, if i did that would ppl test it?

- gwarble

_________________
Notify() | Compile() | Instance() | LV_Group()
EitherMouse
Recommended: AHK_L (don't forget its a superset of _Basic)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2012, 10:39 pm 
gwarble, sure
I would recommend you start a new thread in Scripts & Functions with whatever you want to make, I will be happy to test.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2012, 11:25 pm 
Anonymous wrote:
Can you post a fully working script with all the parameters including attachments using blat?
I don't need to post a script, open a dosbox, write a blat line that works for you, then all you need to "script" is the Run command and insert your variables. Look at the blat docs, really it is a piece of cake.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2012, 2:25 am 
Offline

Joined: May 23rd, 2009, 4:48 am
Posts: 365
Location: north bay, california
Anigav wrote:
gwarble, sure
I would recommend you start a new thread in Scripts & Functions with whatever you want to make, I will be happy to test.


rough draft, but here you go... the more tests from different systems/environments/mailservers will hopefully help us determine the reliable methods to use

http://www.autohotkey.com/forum/viewtopic.php?p=514792

- gwarble

_________________
Notify() | Compile() | Instance() | LV_Group()
EitherMouse
Recommended: AHK_L (don't forget its a superset of _Basic)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2012, 7:35 am 
Offline

Joined: January 20th, 2012, 2:04 pm
Posts: 42
Sorry for the bump, but I can not seem to get any of the scripts posted in this thread to work.

I am using the latest AHK_L version, Windows Vista 32 bit and I have the latest COM version:


This is the error I get
Image

The only one not giving me an error (I had to add #include, COM.ahk) is this one. Unfortunately, even after filling out all of the required fields, it does not send the mail.

Code:
sFrom := "Mail_Address_Of_Sender"
sTo := "Mail_Address_Of_Receipient"
sSubject := "Message_Subject"
sBody := "Message_Text"
sAttach := "Path_Of_Attachment"
mAttrib = From|To|Subject|TextBody
vars2 = sFrom|sTo|sSubject|sBody
StringSplit, Attrib, mAttrib, |

sServer := "smtp.gmail.com" ; specify your SMTP server
nPort := 465 ; 25
bTLS := True ; False
nSend := 2   ; cdoSendUsingPort
nAuth := 1   ; cdoBasic
tOut := 60
url := "http://schemas.microsoft.com/cdo/configuration/"
uSub = sendusing|smtpconnectiontimeout|smtpserver|smtpserverport|smtpusessl|smtpauthenticate|sendusername|sendpassword
vars1 = nSend|tOut|sServer|nPort|bTLS|nAuth|sUsername|sPassword
StringSplit, sub, uSub, |

sUsername := "your_username"
sPassword := "your_password"

pmsg :=   COM_CreateObject("CDO.Message")
pfld :=   pmsg.Configuration.Fields
Loop, Parse, vars1, |
   pfld.Item[url sub%A_Index%]:= %A_LoopField%
pfld.Update()
Loop, Parse, vars2, |
   pmsg[Attrib%A_Index%]:= %A_LoopField%
if sAttach
   Loop, Parse, sAttach, |, %A_Space%%A_Tab%
      pmsg.AddAttachment[A_LoopField]
pmsg.Send()
pfld:=pmsg:=""
return






I have officially tried all of the scripts in this thread, and have read all 190 something posts. I think one or two people had the same issue as me, but resolved their own problem by installing the latest version of AHK(which I have). I even re installed it 5 min. ago to make sure. I believe that this script I should be using, but I still get that error message box.

Code:
#include com.ahk

sFrom      = "Display name" <Youre-mail@gmail.com>
sTo       := "Mail_Address_Of_Receipient"
sBCC =   ; Blind Carbon Copy, Invisable for all, same syntax as CC
sCC = Some-mail@gmail.com, Some-Other-mail@gmail.com, Some-Other-mail@gmail.com ; Carbon Copy , visable to all

sSubject  := "Message_Subject"
sBody     := "Message_Text"
sAttach   := "Path_Of_Attachment" ; can add multiple attachments, the delimiter is |

sServer   := "smtp.gmail.com" ; specify your SMTP server
nPort     := 465 ; 25
bTLS      := True ; False
nSend     := 2   ; cdoSendUsingPort
nAuth     := 1   ; cdoBasic
sUsername := "your_username"   ; What you use to login, eg everything before @gmail.com
sPassword := "your_password"    ; Pasword you use to login
COM_Init()
pmsg :=   COM_CreateObject("CDO.Message")
pcfg :=   COM_Invoke(pmsg, "Configuration")
pfld :=   COM_Invoke(pcfg, "Fields")
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendusing", nSend)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 60)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserver", sServer)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserverport", nPort)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpusessl", bTLS)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", nAuth)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendusername", sUsername)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendpassword", sPassword)
COM_Invoke(pfld, "Update")

COM_Invoke(pmsg, "From", sFrom)
COM_Invoke(pmsg, "To", sTo)
COM_Invoke(pmsg, "BCC", sBCC)
COM_Invoke(pmsg, "CC", sCC)
COM_Invoke(pmsg, "Subject", sSubject)
COM_Invoke(pmsg, "TextBody", sBody)
Loop, Parse, sAttach, |, %A_Space%%A_Tab%
COM_Invoke(pmsg, "AddAttachment", A_LoopField)
COM_Invoke(pmsg, "Send")

COM_Release(pfld)
COM_Release(pcfg)
COM_Release(pmsg)
COM_Term()


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re:
PostPosted: April 13th, 2012, 4:12 pm 
Offline

Joined: April 4th, 2012, 12:13 am
Posts: 17
Location: florida
Xei wrote:
Sorry for the bump, but I can not seem to get any of the scripts posted in this thread to work.


i too have looked near and far for this to work.

using 1.0.48.05 ahk...

when i run the following, it does not load up the com.ahk file, gives me the error (#include file cannot be opened). What am i doing wrong? i have the com.ahk plus the functions.txt in the extras\scripts folder, is that correct?

Code:
#include com.ahk

sFrom      = "fromuser@gmail.com" <fromuser@gmail.com>
sTo       := "touser@gmail.com"
sBCC =    := "someone@else.com" ; Blind Carbon Copy, Invisable for all, same syntax as CC
sCC = Some-mail@gmail.com, Some-Other-mail@gmail.com, Some-Other-mail@gmail.com ; Carbon Copy , visable to all

sSubject  := "Message_Subject"
sBody     := "Message_Text"
sAttach   := "c:\email.ahk" ; can add multiple attachments, the delimiter is |

sServer   := "smtp.gmail.com" ; specify your SMTP server
nPort     := 465 ; 25
bTLS      := True ; False
nSend     := 2   ; cdoSendUsingPort
nAuth     := 1   ; cdoBasic
sUsername := "user"   ; What you use to login, eg everything before @gmail.com
sPassword := "pass"    ; Pasword you use to login
COM_Init()
pmsg :=   COM_CreateObject("CDO.Message")
pcfg :=   COM_Invoke(pmsg, "Configuration")
pfld :=   COM_Invoke(pcfg, "Fields")
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendusing", nSend)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 60)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserver", sServer)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserverport", nPort)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpusessl", bTLS)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", nAuth)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendusername", sUsername)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendpassword", sPassword)
COM_Invoke(pfld, "Update")

COM_Invoke(pmsg, "From", sFrom)
COM_Invoke(pmsg, "To", sTo)
COM_Invoke(pmsg, "BCC", sBCC)
COM_Invoke(pmsg, "CC", sCC)
COM_Invoke(pmsg, "Subject", sSubject)
COM_Invoke(pmsg, "TextBody", sBody)
Loop, Parse, sAttach, |, %A_Space%%A_Tab%
COM_Invoke(pmsg, "AddAttachment", A_LoopField)
COM_Invoke(pmsg, "Send")

COM_Release(pfld)
COM_Release(pcfg)
COM_Release(pmsg)
COM_Term()


edit: fixed the include issue, just had to fully path it. the routine above works as expected, it did mail to the appropriate users.

now how to edit this so that it comes up in a dialog box with the to: from: etc... has that been done?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 199 posts ]  Go to page Previous  1 ... 10, 11, 12, 13, 14  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bon, SKAN, Yahoo [Bot] and 5 guests


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