Jump to content

Recommended Posts

Posted

Hi, I have a program that I am writing to help me automate the task of sending emails using hotmail to my clients.

The emails that I send vary and I have saved a text file that has the email inside it. My application reads from the file and types it into the boxes.

If the text document has breaks in a line, it screws autoit up and apparently was actually sending the {RETURN} key?

It will not send any keys that has line breaks in it.

Here is my script:

$oIE = _IEAttach ("Untitled Message")
    $oToBox = _IEGetObjByName ($oIE, "divTo")
    $oSubjectBox = _IEGetObjById ($oIE , "txtSubj")
    $oBodyBox = _IEGetObjById ( $oIE, "divBdy")
    WinActivate("Message")
    WinWaitActive("Message") ;Function to activate the new message textbox
    _IELoadWait($oIE)
    _IEAction($oToBox, "click")
    Send("chipsanddip12@yahoo.com",1)
    Send ("{ENTER}",0)
    Send ("{TAB}", 0)
    Send ("{TAB}", 0)
    Send ("This is a sample email",1)
    Send ("{TAB}", 0)
    Send ($dob , 0)

func loadPastes()
    $File = FileOpen("cop.txt", 0) ;Functions used to read input from a file and store it in a textbox
    $dob = FileRead($File)
    FileClose($File)
    MsgBox(0, "Loaded successfully", "Copy and Pastes loaded!")
EndFunc
Posted (edited)

Welcome to the forums!

I don't have a Hotmail account to test (dirty!) but on a hunch, try this:

$oIE = _IEAttach ("Untitled Message")
$oToBox = _IEGetObjByName ($oIE, "divTo")
$oSubjectBox = _IEGetObjById ($oIE , "txtSubj")
$oBodyBox = _IEGetObjById ( $oIE, "divBdy")
$oToBox.Value = "chipsanddip12@yahoo.com"
$oSubjectBox.Value = "This is a sample email"
$oBodyBox.Value = $dob

If you have to send a lot of emails, I would heavily consider setting up your Hotmail account in an email client (like Microsoft Outlook) where you can control the sending of emails a lot more reliably... Trying to script the sending of emails via a web-based email system is just plain janky.

Either that or get a GMail account, at which point you can use this to send directly from AutoIt without needing to use a web interface at all: http://www.autoitscript.com/forum/index.php?showtopic=23860

Edited by exodius
Posted

Thanks I've got it working now.

Also thanks for the alternate way of sending the emails, however due to restrictions in my workplace this is the only way I can solve the issue.

I am using this is a 'helper' tool for my job.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...