Jump to content

Recommended Posts

Posted
  On 1/29/2018 at 11:43 AM, Jos said:

You have an mistake in your script, likely something with the workdir, but without showing it, there isn't much we can do.

Jos

Expand  

I figured out what went wrong. You cant attach opened files :).

I didnt wanna post my script cuz im doubtfull you would help me if you saw what it does. 

Ty for ur fast response even 12 years after ur script was made and ofc ty for an amazing script aswell. 

 

  • Developers
Posted
  On 1/31/2018 at 2:15 PM, Zen14 said:

I didnt wanna post my script cuz im doubtfull you would help me if you saw what it does. 

Expand  

Cute...  telling the community that you're into illegal things.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
  On 1/31/2018 at 2:17 PM, Jos said:

Cute...  telling the community that you're into illegal things.

Jos

Expand  

Its just a personal project i dont do illegal things i swear to god. Ur script wont be missused i promise. Im just trying to learn to code man

  • 6 months later...
Posted
  On 3/28/2006 at 8:17 PM, Jos said:

 

;
;##################################
; Include
;##################################
#Include<file.au3>
;##################################
; Variables
;##################################
$SmtpServer = "MailServer"              ; address for the smtp-server to use - REQUIRED
$FromName = "Name"                      ; name from who the email was sent
$FromAddress = "your@Email.Address.com" ; address from where the mail should come
$ToAddress = "your@Email.Address.com"   ; destination address of the email - REQUIRED
$Subject = "Userinfo"                   ; subject from the email - can be anything you want it to be
$Body = ""                              ; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = ""                       ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
$CcAddress = "CCadress1@test.com"       ; address for cc - leave blank if not needed
$BccAddress = "BCCadress1@test.com"     ; address for bcc - leave blank if not needed
$Importance = "Normal"                  ; Send message priority: "High", "Normal", "Low"
$Username = "******"                    ; username for the account used from where the mail gets sent - REQUIRED
$Password = "********"                  ; password for the account used from where the mail gets sent - REQUIRED
$IPPort = 25                            ; port used for sending the mail
$ssl = 0                                ; enables/disables secure socket layer sending - put to 1 if using httpS
;~ $IPPort=465                          ; GMAIL port used for sending the mail
;~ $ssl=1                               ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

;##################################
; Script
;##################################
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
;
; The UDF
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 : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
            If FileExists($S_Files2Attach[$x]) Then
                ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF)
                $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
    ;Authenticated SMTP
    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
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Set Email Importance
    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
    ; Sent the Message
    $objEmail.Send
    If @error Then
        SetError(2)
        Return $oMyRet[1]
    EndIf
    $objEmail=""
EndFunc   ;==>_INetSmtpMailCom
;
;
; Com Error Handler
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); something to check for when this function returns
    Return
EndFunc   ;==>MyErrFunc

 

Edit: Fixed Bcc ...

Edit: Added support for different port and SLL which are used by GMail (Port 465)

Edit: Added Importance support (10/2008)

Expand  

This is bit off topic Question

But I want To Know What Changes i have to do inorder to reply to a particular email

and keep in in thread like format

m using pop3 udf to retrieve emails on gmail

  • 5 weeks later...
Posted

Hey, so I started using this and it works well, but I do have a question.
Under the list of fields, you have this:

 

$Username = ""                           ; username for the account used from where the mail gets sent - REQUIRED
$Password = ""                          ; password for the account used from where the mail gets sent - REQUIRED

What are they required for? I've been leaving them blank and the emails are still being sent. The "from" email I use doesn't exist, so maybe that is why it works for me.


 

Posted

They are required for "Authenticated SMTP", according to comments in the source code of the function.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)

I can't get a line feed in the body. If I try:

$Body = "one" & @CRLF & "two" & @CRLF & "three"

I receive an email with "one two three" as body

I'd like to get:
one
two
three

Any help?

Edited by masvil
Posted (edited)
$Body = "one" & @CRLF & "two" & @CRLF & "three"
.....
.....
$Body = StringReplace($Body,@CRLF,'<br>')
;~ And now you can send your body message....

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 1 year later...
Posted

Hi, i managed to send email with attachment and some body text , but not sure how to add signature converted to html.

Can someone help my with this ?

$Body = ""

example of signature created in online html editor

  Quote

<p>Respected,</p>
<p>In attachemnt is update of report</p>
<p>Best regards</p>
<p><br /> --</p>
<p><strong>FirstName LastName<br /></strong>Position in company</p>
<p><span style="color: #ff0000;"><strong>Company name</strong></span><strong><br /> </strong>_____<strong>Company Group<br /> </strong></p>
<p><strong>tel:</strong>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +111 (0) 11 222 333<br /> <strong>mob: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </strong>+111 (0) 11 222 333</p>
<p><strong>e-mail:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </strong><u><a href="mailto:first.last@sompany.com">firstname.lastname@company.com</a></u><u><br /> </u></p>
<p>Adress, 5000 City/County<br /> <a href="http://www.comp.com">www.company.com</a></p>
<p><img src="https://p1.hiclipart.com/preview/129/7/611/google-chrome-google-logo.jpg" alt="" width="100" height="100" /></p>

Expand  

 

Posted

Which mail client do you use? For Outlook there is an UDF available to fully automate mails etc.

My UDFs and Tutorials:

  Reveal hidden contents

 

  • Developers
Posted
  On 2/20/2020 at 4:13 PM, Zaoka said:

Hi, i managed to send email with attachment and some body text , but not sure how to add signature converted to html.

Can someone help my with this ?

$Body = ""

example of signature created in online html editor

 

Expand  

Just add it at the end of the body should work...no?

Jos

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Use single quote to enclose the html code:

$sBody = '<p>Respected,</p>' & _
'<p>In attachemnt is update of report</p>' & _
'<p>Best regards</p>' & _
'<p><br /> --</p>' & _
'<p><strong>FirstName LastName<br /></strong>Position in company</p>' & _
'<p><span style="color: #ff0000;"><strong>Company name</strong></span><strong><br /> </strong>_____<strong>Company Group<br /> </strong></p>' & _
'<p><strong>tel:</strong>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +111 (0) 11 222 333<br /> <strong>mob: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </strong>+111 (0) 11 222 333</p>' & _
'<p><strong>e-mail:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </strong><u><a href="mailto:first.last@sompany.com">firstname.lastname@company.com</a></u><u><br /> </u></p>' & _
'<p>Adress, 5000 City/County<br /> <a href="http://www.comp.com">www.company.com</a></p>' & _
'<p><img src="https://p1.hiclipart.com/preview/129/7/611/google-chrome-google-logo.jpg" alt="" width="100" height="100" /></p>'

 

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  On 2/20/2020 at 4:47 PM, water said:

Use single quote to enclose the html code:

$sBody = '<p>Respected,</p>' & _
'<p>In attachemnt is update of report</p>' & _
'<p>Best regards</p>' & _
'<p><br /> --</p>' & _
'<p><strong>FirstName LastName<br /></strong>Position in company</p>' & _
'<p><span style="color: #ff0000;"><strong>Company name</strong></span><strong><br /> </strong>_____<strong>Company Group<br /> </strong></p>' & _
'<p><strong>tel:</strong>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +111 (0) 11 222 333<br /> <strong>mob: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </strong>+111 (0) 11 222 333</p>' & _
'<p><strong>e-mail:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </strong><u><a href="mailto:first.last@sompany.com">firstname.lastname@company.com</a></u><u><br /> </u></p>' & _
'<p>Adress, 5000 City/County<br /> <a href="http://www.comp.com">www.company.com</a></p>' & _
'<p><img src="https://p1.hiclipart.com/preview/129/7/611/google-chrome-google-logo.jpg" alt="" width="100" height="100" /></p>'

 

Expand  

Yes it worked, did not know about single quote 😀 , THANKS a lot

  • 3 months later...
  • Developers
Posted (edited)
  On 5/23/2020 at 11:52 AM, lenclstr746 said:

I can't send turkish character like ş ü ğ ç ö ı what ı can ?

Expand  

You should be able to do that but likely need to urlencode() the text first.
See this topic for an example of an urlencode() udf.

Post an example script when it still doesn't work.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

  • 4 weeks later...
Posted

Just an FYI that I used this today and it's still working like a charm.  Thank you for providing this so long ago and making the updates you have.  It's VERY useful!

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