Sign in to follow this  
Followers 0
infaf711

Automate Windows Live Mail (Like you can do with outlook)

8 posts in this topic

Hello everyone. I have been trying to create a script that will work with another one of my programs that when you click "email this person" in my program it will run a script that opens up Windows Live Mail and creates a new email and will populate the To, Subject, CC's, and add attachments. I know you can do this fairly easy with outlook but I cant seem to find a way to do this with Windows Live Mail. I would love if anyone could help.

Share this post


Link to post
Share on other sites



hello infaf711, welcome to AutoIt forum!

you picked the wrong tool for the job. Windows Live Mail has no automation interface, except only ASP.NET SDK which seems to require too much investment for too little result. your options are:

1) write ASP.NET app to do it

2) automate partly by command line switches (all except attachment and cc, me think). the rest is by ConstrolSend() & ControlClick()

3) use another mail client, or perhaps >this.

Share this post


Link to post
Share on other sites

Thanks!

But that stinks, I wanted to see if there was a way to give people that don't want to have to buy outlook another option through the Live Mail. But you're right on it being too much of an investment, but thank you anyway!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

infaf711,

If all you want to do is send mail to an email address with attachments you can do that without having to interact with any email client.

I am currently using Windows Live Mail and regularly send email using SMTP.  I am using an old/modified version of _INetSMTPMail.  I have not used the distributed version yet.  It may be all that you need.

kylomas

edit: corrected function name

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

@kylomas, care to share your "old/modified version of _INetSMTPMail" ? the current version does not seem to support attachments.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Forgive me if i am wrong, but like kylo said, can you simply not use CDO?

I know that this script i use supports attachments just fine.. i use it every day..

#Include<file.au3>
#include<ie.au3>

Global $smtpserver = "" ;smtpserver address
Global $fromname = ""
Global $fromaddress = ""
Global $toaddress = ""
Global $subject = ""
Global $body = "Greetings," & @CRLF & @CRLF & "This is an automated email please do not reply"
Global $attachfiles = "" ;filepath to file you want to attach
Global $ccaddress = ""
Global $bccaddress = ""
Global $importance = "Normal"
Global $username = ""
Global $password = ""
Global $ipport = 25
Global $ssl = 0
Global $omyret[2]
Global $omyerror = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _inetsmtpmailcom($smtpserver, $fromname, $fromaddress, $toaddress, $subject, $body, $attachfiles, $ccaddress, $bccaddress, $importance, $username, $password, $ipport, $ssl)
If @error Then
    MsgBox(0, "Error sending message", "Error code:" & @error & "  Description:" & $rc)
EndIf

Func _inetsmtpmailcom($s_smtpserver, $s_fromname, $s_fromaddress, $s_toaddress, $s_subject = "", $as_body = "", $s_attachfiles = "", $s_ccaddress = "", $s_bccaddress = "", $s_importance = "Normal", $s_username = "", $s_password = "", $ipport = 25, $ssl = 0)
    Local $objemail = ObjCreate("CDO.Message")
    $objemail.from = '"' & $s_fromname & '" <' & $s_fromaddress & ">"
    $objemail.to = $s_toaddress
    Local $i_error = 0
    Local $i_error_desciption = ""
    If $s_ccaddress <> "" Then $objemail.cc = $s_ccaddress
    If $s_bccaddress <> "" Then $objemail.bcc = $s_bccaddress
    $objemail.subject = $s_subject
    If StringInStr($as_body, "<") AND StringInStr($as_body, ">") Then
        $objemail.htmlbody = $as_body
    Else
        $objemail.textbody = $as_body & @CRLF
    EndIf
    If $s_attachfiles <> "" Then
        Local $s_files2attach = StringSplit($s_attachfiles, ";")
        For $x = 1 To $s_files2attach[0]
            $s_files2attach[$x] = _pathfull($s_files2attach[$x])
            ConsoleWrite("@@ Debug(62) : $S_Files2Attach = " & $s_files2attach & @LF & ">Error code: " & @error & @LF)
            If FileExists($s_files2attach[$x]) Then
                $objemail.addattachment($s_files2attach[$x])
            Else
                ConsoleWrite("!> File not found to attach: " & $s_files2attach[$x] & @LF)
                SetError(1)
                Return 0
            EndIf
        Next
    EndIf
    $objemail.configuration.fields.item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objemail.configuration.fields.item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_smtpserver
    If Number($ipport) = 0 Then $ipport = 25
    $objemail.configuration.fields.item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $ipport
    If $s_username <> "" Then
        $objemail.configuration.fields.item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        $objemail.configuration.fields.item("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_username
        $objemail.configuration.fields.item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_password
    EndIf
    If $ssl Then
        $objemail.configuration.fields.item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    $objemail.configuration.fields.update
    Switch $s_importance
        Case "High"
            $objemail.fields.item("urn:schemas:mailheader:Importance") = "High"
        Case "Normal"
            $objemail.fields.item("urn:schemas:mailheader:Importance") = "Normal"
        Case "Low"
            $objemail.fields.item("urn:schemas:mailheader:Importance") = "Low"
    EndSwitch
    $objemail.fields.update
    $objemail.send
    If @error Then
        SetError(2)
        Return $omyret[1]
    EndIf
    $objemail = ""
EndFunc

Exit

Func myerrfunc()
    $hexnumber = Hex($omyerror.number, 8)
    $omyret[0] = $hexnumber
    $omyret[1] = StringStripWS($omyerror.description, 3)
    ConsoleWrite("### COM Error !  Number: " & $hexnumber & "   ScriptLine: " & $omyerror.scriptline & "   Description:" & $omyret[1] & @LF)
    SetError(1)
    Return
EndFunc
Edited by 13lack13lade

Share this post


Link to post
Share on other sites

@13lack13blade, that is what i referred to here:

... or perhaps >this.

Share this post


Link to post
Share on other sites

orbs,

Let me test attachments.  I have not sent an attachment since upgrading to Live Mail.  It is similar to what 13lack13lade posted.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0