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
Eraserhead
  • Members
  • 24 posts
  • Last active: Jun 16 2015 03:20 AM
  • Joined: 23 Feb 2013

Thanks for this example script, it worked well for me.

 

Does anyone know how to use the Fileread command to read a file and then output the contents of that file in the e-mail text body? I used this:

FileRead, Droplogvar, C:\Users\Snoopy\Desktop\Droplog.txt

pmsg.TextBody     := "%Droplogvar%"

But that doesn't seem to work.

 

Also i tried putting the computer name and IP in the subject line but that doesn't seem to work either.

pmsg.Subject     := "A_ComputerName with address A_IPAddress1 is done!"


gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
pmsg.TextBody := DropLogvar
pmsg.Subject := A_ComputerName " has..."

Eraserhead
  • Members
  • 24 posts
  • Last active: Jun 16 2015 03:20 AM
  • Joined: 23 Feb 2013

Thanks, that worked. Those damn quotes wink.png



ytzyz
  • Members
  • 3 posts
  • Last active: Dec 06 2013 11:51 PM
  • Joined: 29 Nov 2013
How to wait until all the attachment was sent and them delete the attachment in the local computer because the size is different, dont know exactly how long it need to send attachment

Wait gmail deliver all the attachment
Filedelete c:\*.zip

hamncheese
  • Members
  • 48 posts
  • Last active: Jan 16 2017 12:17 AM
  • Joined: 23 May 2012

Hello, Thank you Shajul for this wonderful script, this script has made my life so much easier :D

and im running a little trouble and hoping some direction on how to manage this

so this is what im trying to achieve

 

Window A running > send hotkey > takes screenshot > send email + latest screenshot

 

i have no problem when using full path as the attachment address, email + attachment is sent successfully, but with this i cannot send the latest screenshot

so then this is what i have tried

 

ive added a Loop File/Folder on top of the Script

checking with MsgBox confirms that the file path and the latest screenshot is created correctly

 Loop, C:\Users\xxx\Documents\SomeRandomProgram\Screenshots\*.png
            {
                If (A_LoopFileTimeCreated>Rec)
                {
                    FPath=%A_LoopFileFullPath%
                    Rec=%A_LoopFileTimeCreated%
                }
            }
            msgbox, %FPath%

and the using the file path generated from %FPath%

i add that into the script

  pmsg             := ComObjCreate("CDO.Message")
            pmsg.From         := """John Doe"" <FromEmail@gmail.com>"
            pmsg.To         := "ToEmail@gmail.com"
            pmsg.BCC         := ""
            pmsg.CC         := ""
            pmsg.Subject     := "Subject"

            ;You can use either Text or HTML body like
            pmsg.TextBody     := "BodyMessage"
            ;OR
            ;pmsg.HtmlBody := "<html><head><title>Hello</title></head><body><h2>Hello</h2><p>Testing!</p></body></html>"


            sAttach         := "%FPath%" ; this is where i add the file path

            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 := "MyEmail@gmail.com"
            fields.sendpassword := "MyPassword"
            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()

and this is the Error ive got

Ddf77U8.png

 

Hopefully someone can help and shed some light for me, thank you for anyone reading this

ps: im sorry for the bad english

:)

 

edit :

this is the whole script

F3::        
            controlsend,, {F2}, SomeRandomProgramWindow
            Loop, C:\Users\xxx\Documents\SomeRandomProgram\Screenshots\*.png
            {
                If (A_LoopFileTimeCreated>Rec)
                {
                    FPath=%A_LoopFileFullPath%
                    Rec=%A_LoopFileTimeCreated%
                }
            }
            pmsg             := ComObjCreate("CDO.Message")
            pmsg.From         := """John Doe"" <FromEmail@gmail.com>"
            pmsg.To         := "ToEmail@gmail.com"
            pmsg.BCC         := ""
            pmsg.CC         := ""
            pmsg.Subject     := "Subject"

            ;You can use either Text or HTML body like
            pmsg.TextBody     := "BodyMessage"
            ;OR
            ;pmsg.HtmlBody := "<html><head><title>Hello</title></head><body><h2>Hello</h2><p>Testing!</p></body></html>"


            sAttach         := "%FPath%" ; 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 := "MyEmail@gmail.com"
            fields.sendpassword := "MyPassword"
            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()



malcev
  • Members
  • 73 posts
  • Last active: Jan 28 2016 08:05 PM
  • Joined: 19 May 2011
How to check that email is sent with msgbox but not with ComObjError?
 
send_email("All Ok", "CC@test.com")

send_email(Text, CC)
{
   ComObjError(false)
   pmsg := ComObjCreate("CDO.Message")
   pmsg.From := "from@test.com"
   pmsg.To := "to@test.com"
   pmsg.CC := CC
   pmsg.Subject := "Message_Subject"
   pmsg.TextBody := Text
   fields := Object()
   fields.smtpserver := "mail.test.com" ; specify your SMTP server
   fields.smtpserverport := 25
   fields.smtpusessl := True ; False
   fields.sendusing := 2   ; cdoSendUsingPort
   fields.smtpauthenticate := 1   ; cdoBasic
   fields.sendusername := "from@test.com"
   fields.sendpassword := "pass"
   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()
   pmsg.Send()
   return
}


jchristl
  • Members
  • 42 posts
  • Last active: Apr 03 2016 10:27 PM
  • Joined: 13 Jan 2006

Hi.  I am trying send a message with High Importance,  How can that be added to the script?