Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

CDO COM - Email Delivery [AHK_L]


  • Please log in to reply
66 replies to this topic
  • Guests
  • Last active:
  • Joined: --
@jpbirdsong
I keep getting unknown recipient(s) error, even though its good.
Does it depend on Outlook? I have it removed from my system.

GeekDude
  • Spam Officer
  • 391 posts
  • Last active: Oct 05 2015 08:13 PM
  • Joined: 23 Nov 2009
Any way to deliver anonymous email without using outlook?
like, cdo.message but without the authentication part

rbrtryn
  • Members
  • 1177 posts
  • Last active: Sep 11 2013 08:04 PM
  • Joined: 22 Jun 2011

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

This error means you failed to log on to the SMTP server. Possible reasons:[*:1ixnxgek]You suppilied an incorrect password.[*:1ixnxgek]You suppilied an incorrect user name.[*:1ixnxgek]The server was unreachable for some reason. Maybe down or firewalled.

My Scripts are written for the latest released version of AutoHotkey.

Need a secure, accessible place to backup your stuff? Use Dropbox!


grutcblu
  • Members
  • 4 posts
  • Last active: Feb 03 2013 02:20 PM
  • Joined: 08 Nov 2012
Hello,

I've tried this script as it does exactly what I want.
However, I get the message

"incorrect class string" (chaine de classe incorrecte)

on line

pmsg := ComObjCreate("CDO.Message")

I haven't installed COM_L.ahk since the topic says it's not necessary.
I run XP 32 bits, latest version of AHK.
Any idea?

Thanks a lot

krajan
  • Members
  • 51 posts
  • Last active: Oct 02 2014 06:31 PM
  • Joined: 03 Oct 2011

Hi

It works perfect for me. Thanks... but...

In case of lost internet connection [or any other reason] I receive error message. Is there a way to skip the message and continue? 

So if the program can't send an email waits some time and try again [without the message]

 

Possible?

Thanks



GeekDude
  • Spam Officer
  • 391 posts
  • Last active: Oct 05 2015 08:13 PM
  • Joined: 23 Nov 2009

Look at the Try and Catch statements in the documentation



defTwitch
  • Members
  • 1 posts
  • Last active: Oct 13 2013 08:50 PM
  • Joined: 08 Mar 2013

Hello,

I've tried this script as it does exactly what I want.
However, I get the message

"incorrect class string" (chaine de classe incorrecte)

on line

pmsg := ComObjCreate("CDO.Message")

I haven't installed COM_L.ahk since the topic says it's not necessary.
I run XP 32 bits, latest version of AHK.
Any idea?

Thanks a lot

 

I'm trying to get this and similar versions of this script working as well and I keep getting an error on the line with:

pmsg := ComObjCreate("CDO.Message")

 

At run I get:

Error:  Call to nonexistent function.

Specifically: COM_CreateObject("CDO.Message")

 

I also thought we didn't have to add any COM library etc. from the reading I've done on here and that all that's included now in AHK_L.  I double checked my install and believe everything should be in order.

 

I double checked here:  http://www.autohotke...ahk-l/?p=384797

 

I have outlook installed (but never use it).  Do I need accounts setup there?  I only ask because of this: http://www.autohotke...ahk-l/?p=385106

DEPENDENCIES:
This script requires that Outlook or another MAPI based mail client be installed

 

Any help appreciated.  On multiple machines I get that error every time for nonexistent function.

 

Thanks



equipment66
  • Members
  • 2 posts
  • Last active: Jul 05 2014 04:01 AM
  • Joined: 11 Mar 2013

Hello,

 

Could you please explain, how to add information about message body encoding to this script? Often I need to send an e-mails with various encoding to recipients and there is some complicated to read content easily.

 

Thanks in advance

 

 

Just creating a new thread for AHK_L users of CDO COM - Email delivery by Sean - all credits to him.

infogulch and sinkfaze modified versions here!

No need to include COM_L.ahk
 

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()

Edit1: Much shorter code with For-loop
Edit2: CC and BCC, thanks emmanuel d


Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

the code performs flaulessly on my XP. but when i run it on Win 7, i get the following error message:

 

Error: 0x800401F3 - Invalid class string

         Line#

--->   pmsg := ComObjCreate("CDO.Message")

 

any ideas?



Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

the following script is another variation that runs fine on XP (w/ Outlook Express) but throws a different error message on Win7 (w/ Windows Live Mail):

Function Name: "Configuration"

ERROR: No COM Dispatch Object!

             ()

#include C:\...\COM.ahk

sFrom := "xxx"
sTo := "xxx"
sSubject := "xxx"
sBody := "xxx"
sAttach := "" ; "Path_Of_Attachment"

mAttrib = From|To|Subject|TextBody
vars2 = sFrom|sTo|sSubject|sBody
StringSplit, Attrib, mAttrib, |

sServer := "xxx" ; specify your SMTP server
nPort := 465 ; 25
bTLS := True ; False
nSend := 2   ; cdoSendUsingPort
nAuth := 1   ; cdoBasic
tOut := 60
sUsername := "xxx"
sPassword := "xxx"

uSub = sendusing|smtpconnectiontimeout|smtpserver|smtpserverport|smtpusessl|smtpauthenticate|sendusername|sendpassword
vars1 = nSend|tOut|sServer|nPort|bTLS|nAuth|sUsername|sPassword
StringSplit, sub, uSub, |

url := "http://schemas.microsoft.com/cdo/configuration/"

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


Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

i identified the messaging object (CDO) in Win7, which is cdosys.dll and resides in system32 directory. so it is not missing from my Win7 OS. but still i receive:

 

Error: 0x800401F3 - Invalid class string

         Line#

--->   pmsg := ComObjCreate("CDO.Message")



Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

i am aware that the standard reply would be REGISTER the cdosys.dll. Or un-register/register the cdosys.dll. but do this at your own risk of hosing your machine (UNTESTED):

 

1. Confirm cdosys.dll path in your system32 directory
2. Un-register with c:\windows\system32>regsvr32 c:\windows\system32\cdosys.dll /u
3. Register with c:\windows\system32>regsvr32 c:\windows\system32\cdosys.dll
4. Re-boot

 

1. KEY_LOCAL_MACHINE/Software/Classes/CLASS_NAME
(Keep in mind CLASS_NAME will be replaced with the class name you are trying to instantiate)
Right click on it and then Permissions. Allow Full Access for SYSTEM and Administrator. (To be sure it works add "CREATOR OWNER" and "Users" users and allow Full Access to those too.)

2. KEY_LOCAL_MACHINE/Software/Classes/CLASS_NAME has a folder called CLASSID under it. Click on it and on the right side will appear the code of the class. This code you will type it in place of CLASS_ID in the following step:

3. Go to HKEY_LOCAL_MACHINE/Software/Classes/CLSID/{CLASS_ID} and add the same permissions as in step 1. Restart the computer and try run the script.

 

These error messages can appear for a few reasons. Some of the common reasons include

  • Invalid class string 
  • Unregistered DLL files
  • Invalid permissions

Also, see http://www.autohotke...d-class-string/

and http://www.autohotke...ressions/page-2



shoufanzaid
  • Members
  • 2 posts
  • Last active: Jun 12 2013 02:13 AM
  • Joined: 09 Jun 2013

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^^

 

I have the same problem as Da Prein. Ports 25 and 587 don't work for me, so I'm using 465. I have no idea if that noname problem is related to ports, but my code used to work just fine before I got obligated to transfer to _L after I couldn't solve errors mentioned by Guest10 in the posts above.

 

So Da Prein, if you've found the solution, please share. Or if anyone knows it'd be cool. I'll be testing some other things.

 

By the way, for the people that get error messages, CAPITAL LETTERS KILL IT! Don't use caps in your code, like me, when you wanna make it all beautiful. Did not know it was case sensitive. Lost 10 minutes on that lol.

 

**EDIT**

Okay.... For the noname I put my file elsewhere and referred to it. I think using no full path (going for same folder) doesn't work. You could try full path, maybe it'll work. Good luck!



exnius
  • Members
  • 28 posts
  • Last active: Jun 28 2014 01:48 AM
  • Joined: 10 Jul 2013

Works perfect! Thank you very much...



conradcliff
  • Members
  • 31 posts
  • Last active: Dec 11 2013 09:53 PM
  • Joined: 04 Jul 2008

Hey guys, I have this piece of code that's been working for quite a while but now we're getting a " Must issue a STARTTLS command first."

Not sure what changed... :-/

 

Here's the code, any help would be very appreciated :)  :

pmsg          := ComObjCreate("CDO.Message")
				pmsg.From       := """Its Me"" <me@me.com>"
				pmsg.To       := "someone@somewhere.com" 
				pmsg.BCC       := ""   ; Blind Carbon Copy, Invisable for all, same syntax as CC
				pmsg.CC       := ""     ; Separate addresses with commas
				pmsg.Subject    := "subject time"

				;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         := Attachment ; can add multiple attachments, the delimiter is |

				fields := Object()
				fields.smtpserver   := "smtp.gmail.com" ; specify your SMTP server
				fields.smtpserverport     := 587 ; 25
				fields.smtpusetls      := True ; False
				fields.sendusing     := 2   ; cdoSendUsingPort
				fields.smtpauthenticate     := 1   ; cdoBasic
				fields.sendusername := "me@me.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)
				  
				sleep 500
				  
				pmsg.Send()