Sign in to follow this  
Followers 0
Gerry

_INetSmtpMail

7 posts in this topic

Hi all

Only found "_INetSmtpMail " today, very handy. :whistle:

I was wondering if there may been an update for this UDF?

I have program that does a PC audit and want to attach this to email

Is there any way to attach a file to the email using "_INetSmtpMail "?

It would also be nice if one could select multiple email recipients, which

I suppose won't be a train smash to do my self but if an updated version

of the UDF already caters for this, why reinvent the wheel?

Rgds

Gerry

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Use the full path in $e_File, not the partial path. eg: "C:\Documents and Settings\All Users\Desktop\Cookie.jpg"

I reinvented the wheel because I knew how to do it. ^^

$smtpserver = "test.non.existant"
$smtpuser = "username"
$smtppass = "password"

; use the function here!

Func SendEmail($e_Sender, $e_Recipient, $e_Subject, $e_Text,$e_File)
    $objMessage = ObjCreate ("CDO.Message")
    With $objMessage
        .Subject = $e_Subject
        .Sender = $e_Sender
        .From = $e_Sender
        .To = $e_Recipient
        .TextBody = $e_Text
        ;.HtmlBody = $e_Text ; uncomment to send a HTML mail and comment line above
        .AddAttachment = $e_File
    EndWith
    With $objMessage.Configuration.Fields
        .Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $smtpserver
        .Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        .Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $smtpuser
        .Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $smtppass
        .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        .Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
        .Update
    EndWith
    $objMessage.Send
    Return
EndFunc
Edited by Manadar

Share this post


Link to post
Share on other sites

Thanks, you are too clever!

This will solve a lot of my problems. You did not perhaps solve the other wheel with the multiple recipients too?

Just kidding, I will just create a loop and rrsend it.

Thanks again.

Gerry

Share this post


Link to post
Share on other sites

I may be using it wrongly but I get the following errors

C:\SMTP&Attachment.au3 (23) : ==> The requested action

with this object has failed.:

.AddAttachment = $e_File

.AddAttachment = $e_File^ ERROR

I added my details to the original script and then used the

senemail function.

If I removed the "$e_File ", it still had this error

"AddAttachment = $e_File^ ERROR"

Gerry

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hmm.. I can't get it to work either. This website says I am doing it in the right way.

$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

$objMessage = ObjCreate ("CDO.Message")
With $objMessage
    .Subject = "Example CDO Message"
    .Sender = "email@gmail.com"
    .From = "Manadar"
    .To = "email@gmail.com"
    .TextBody = "This is a example CDO Message"
    ;.HtmlBody = $e_Text ; uncomment to send a HTML mail and comment line above
    .AddAttachment = "C:\Documents and Settings\Jos\Desktop\t-shirt.jpg"
EndWith
With $objMessage.Configuration.Fields
    .Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "****.********.**" ; <== SMTP SERVER
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    .Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "*******" ; <== SMTP USERNAME
    .Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "*******" ; <== SMTP PASSWORD
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    .Update
EndWith
$objMessage.Send


Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)    ; for displaying purposes
  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF _
            )
  SetError(1)  ; to check for after this function returns
Endfunc
Edited by Manadar

Share this post


Link to post
Share on other sites

To get the file attachment process in this code to work I included the following:

#Include<file.au3> (to fix the attachment problem)

#include <Date.au3> (if you want a date time stamp information in the Email)

#include <Inet.au3> (if you want Public IP information in the Email)

;Date Time Stamp

$datetimestamp = (@MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC)

;Email File Attachment Processing

;

$files = (@scriptdir & "\" & (@yday) & "dailyLog.txt") ;daily log file to attach

Func yournameconvention()

$PublicIP = _GetIP() ; get the public IP address

$Files = _PathFull ($Files) ; process the files path

.

.

.

With $objMessage

.Subject = ("Your Message " & $var16)

.Sender = $var13

.From = $var12

.To = $var14

.TextBody = ("Your Message" & $datetimestamp & " Public IP " & $PublicIP & " " & @LF & @LF & "End of Message")

.AddAttachment($Files)

EndWith

EndFunc

I am not an expert but I like the challenge of finding solutions

Cheers Ant

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