rony2006

Autoit- Gmail (send mail)

20 posts in this topic

Hello,

 

I want to send a mail using gmail but the script from this forum is not working,

Do you have any other solutions?

 

This is my code:

;
;##################################
; Include
;##################################
#Include<file.au3>
;##################################
; Variables
;##################################
$title = "gfdgfd"
$SmtpServer = "smtp.gmail.com"    ; address for the smtp-server to use - REQUIRED
$FromName = "Cdsan"                 ; name from who the email was sent
$FromAddress = "xxxx@gmail.com"; address from where the mail should come
$ToAddress = "xxxx2@gmail.com" ; destination address of the email - REQUIRED
$Subject = "subiect"                ; 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 you want to attach- leave blank if not needed
$CcAddress = ""  ; address for cc - leave blank if not needed
$BccAddress = ""; address for bcc - leave blank if not needed
$Importance = "Normal"                ; Send message priority: "High", "Normal", "Low"
$Username = "xxxx@gmail.com"                ; username for the account used from where the mail gets sent - REQUIRED
$Password = "pass"                ; password for the account used from where the mail gets sent - REQUIRED
$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")
; 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(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF);### Debug Console
            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
  ;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#Include<file.au3>

 

When running it I get:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\Marian\Desktop\Chart Example.au3"    
>Exit code: 0    Time: 0.2937

 

Share this post


Link to post
Share on other sites



1 hour ago, Jos said:

What did you do with the line that calls the Func? :)

Jos

What you mean? 

I don't get it.

can you give my a working example please?

 

 

Share this post


Link to post
Share on other sites

Well, you took a working example and took out the line starting with:

_INetSmtpMailCom($SmtpServer,

Have a look at the original you copied.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
6 minutes ago, Jos said:

Well, you took a working example and took out the line starting with:

_INetSmtpMailCom($SmtpServer,

Have a look at the original you copied.

Jos

Yeah, you are right. 

I added:

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

 

Now I get the following error:

eror.png

Share this post


Link to post
Share on other sites

I found that solution on internet, but still is not working. :(

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

try this script

 

EDIT: SORRY, I LEAVED ONE FUNCTION WITH WRONG NAME. TRY THIS ONE

 

#include <File.au3>

; ===============================================================================================================================
; Variables for the _INetSmtpMailCom
; ===============================================================================================================================
Global Enum _
        $g__INetSmtpMailCom_ERROR_FileNotFound = 1, _
        $g__INetSmtpMailCom_ERROR_Send, _
        $g__INetSmtpMailCom_ERROR_ObjectCreation, _
        $g__INetSmtpMailCom_ERROR_COUNTER

Global Const $g__cdoSendUsingPickup = 1 ; Send message using the local SMTP service pickup directory.
Global Const $g__cdoSendUsingPort = 2 ; Send the message using the network (SMTP over the network). Must use this to use Delivery Notification
Global Const $g__cdoAnonymous = 0 ; Do not authenticate
Global Const $g__cdoBasic = 1 ; basic (clear-text) authentication
Global Const $g__cdoNTLM = 2 ; NTLM
Global $gs_thoussep = "."
Global $gs_decsep = ","
Global $sFileOpenDialog = ""

; Delivery Status Notifications
Global Const $g__cdoDSNDefault = 0 ; None
Global Const $g__cdoDSNNever = 1 ; None
Global Const $g__cdoDSNFailure = 2 ; Failure
Global Const $g__cdoDSNSuccess = 4 ; Success
Global Const $g__cdoDSNDelay = 8 ; Delay


_Sendmail()



Func _Sendmail()
    Local $sSmtpServer = "smtp.gmail.com" ; address for the smtp-server to use - REQUIRED
    Local $sFromName = "user" ; name from who the email was sent
    Local $sFromAddress = "youremail@gmail.com" ; address from where the mail should come
    Local $sToAddress = "mailreceiver@gmail.com" ; destination address of the email - REQUIRED
    Local $sSubject = "testing" ; subject from the email - can be anything you want it to be
    Local $sBody = "test" ; the messagebody from the mail - can be left blank but then you get a blank mail
    Local $sAttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
    Local $sCcAddress = "" ; address for cc - leave blank if not needed
    Local $sBccAddress = "" ; address for bcc - leave blank if not needed
    Local $sImportance = "Normal" ; Send message priority: "High", "Normal", "Low"
    Local $sUsername = "youremail@gmail.com" ; username for the account used from where the mail gets sent - REQUIRED
    Local $sPassword = "xxxxxxx" ; password for the account used from where the mail gets sent - REQUIRED
    Local $iIPPort = 465 ; GMAIL port used for sending the mail
    Local $bSSL = True ; GMAIL enables/disables secure socket layer sending - set to True if using httpS


    Local $bIsHTMLBody = False
    Local $iDSNOptions = $g__cdoDSNDefault

    Local $rc = _INetSmtpMailCom($sSmtpServer, $sFromName, $sFromAddress, $sToAddress, $sSubject, $sBody, $sAttachFiles, $sCcAddress, $sBccAddress, $sImportance, $sUsername, $sPassword, $iIPPort, $bSSL, $bIsHTMLBody, $iDSNOptions)
    If @error Then
        MsgBox(0, "_INetSmtpMailCom(): Error sending message", _
                "Error code: " & @error & @CRLF & @CRLF & _
                "Error Hex Number: " & _INetSmtpMailCom_ErrHexNumber() & @CRLF & @CRLF & _
                "Description: " & _INetSmtpMailCom_ErrDescription() & @CRLF & @CRLF & _
                "Description (rc): " & $rc & @CRLF & @CRLF & _
                "ScriptLine: " & _INetSmtpMailCom_ErrScriptLine() _
                )
        ConsoleWrite("### COM Error !  Number: " & _INetSmtpMailCom_ErrHexNumber() & "   ScriptLine: " & _INetSmtpMailCom_ErrScriptLine() & "   Description:" & _INetSmtpMailCom_ErrDescription() & @LF)
    Else
        Dim $iMsgBoxAnswer
        $iMsgBoxAnswer = MsgBox(262208, "SUCCESS", ":-)", 5)
    EndIf

EndFunc   ;==>_Enviarmail



#Region UDF Functions
; The UDF
; #FUNCTION# ====================================================================================================================
; Name ..........: _INetSmtpMailCom
; Description ...:
; Syntax ........: _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[, $bSSL = False[, $bIsHTMLBody = False[, $iDSNOptions = $g__cdoDSNDefault]]]]]]]]]]]])
; Parameters ....: $s_SmtpServer        - A string value.
;                  $s_FromName          - A string value.
;                  $s_FromAddress       - A string value.
;                  $s_ToAddress         - A string value.
;                  $s_Subject           - [optional] A string value. Default is "".
;                  $s_Body              - [optional] A string value. Default is "".
;                  $s_AttachFiles       - [optional] A string value. Default is "".
;                  $s_CcAddress         - [optional] A string value. Default is "".
;                  $s_BccAddress        - [optional] A string value. Default is "".
;                  $s_Importance        - [optional] A string value. Default is "Normal".
;                  $s_Username          - [optional] A string value. Default is "".
;                  $s_Password          - [optional] A string value. Default is "".
;                  $IPPort              - [optional] An integer value. Default is 25.
;                  $bSSL                - [optional] A binary value. Default is False.
;                  $bIsHTMLBody         - [optional] A binary value. Default is False.
;                  $iDSNOptions         - [optional] An integer value. Default is $g__cdoDSNDefault.
; Return values .: None
; Author ........: Jos
; Modified ......: mLipok
; Remarks .......:
; Related .......: http://www.autoitscript.com/forum/topic/23860-smtp-mailer-that-supports-html-and-attachments/
; Link ..........: http://www.autoitscript.com/forum/topic/167292-smtp-mailer-udf/
; Example .......: Yes
; ===============================================================================================================================
Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $s_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance = "Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $bSSL = False, $bIsHTMLBody = False, $iDSNOptions = $g__cdoDSNDefault)
    ; init Error Handler
    _INetSmtpMailCom_ErrObjInit()

    Local $objEmail = ObjCreate("CDO.Message")
    If Not IsObj($objEmail) Then Return SetError($g__INetSmtpMailCom_ERROR_ObjectCreation, Dec(_INetSmtpMailCom_ErrHexNumber()), _INetSmtpMailCom_ErrDescription())

    ; Clear previous Err information
    _INetSmtpMailCom_ErrHexNumber(0)
    _INetSmtpMailCom_ErrDescription('')
    _INetSmtpMailCom_ErrScriptLine('')

    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress

    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject

    ; Select whether or not the content is sent as plain text or HTM
    If $bIsHTMLBody Then
        $objEmail.Textbody = $s_Body & @CRLF
    Else
        $objEmail.HTMLBody = $s_Body
    EndIf

    ; Add Attachments
    If $s_AttachFiles <> "" Then
        Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
        For $x = 1 To $S_Files2Attach[0]
            $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
            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)
                Return SetError($g__INetSmtpMailCom_ERROR_FileNotFound, 0, 0)
            EndIf
        Next
    EndIf

    ; Set Email Configuration
    $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = $g__cdoSendUsingPort
    $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") = $g__cdoBasic
        $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
    $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = $bSSL

    ;Update Configuration 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

    ; Set DSN options
    If $iDSNOptions <> $g__cdoDSNDefault And $iDSNOptions <> $g__cdoDSNNever Then
        $objEmail.DSNOptions = $iDSNOptions
        $objEmail.Fields.Item("urn:schemas:mailheader:disposition-notification-to") = $s_FromAddress
;~      $objEmail.Fields.Item("urn:schemas:mailheader:return-receipt-to") = $s_FromAddress
    EndIf

    ; Update Importance and Options fields
    $objEmail.Fields.Update

    ; Sent the Message
    $objEmail.Send

    If @error Then
        _INetSmtpMailCom_ErrObjCleanUp()
        Return SetError($g__INetSmtpMailCom_ERROR_Send, Dec(_INetSmtpMailCom_ErrHexNumber()), _INetSmtpMailCom_ErrDescription())
    EndIf

    ; CleanUp
    $objEmail = ""
    _INetSmtpMailCom_ErrObjCleanUp()

EndFunc   ;==>_INetSmtpMailCom

;
; Com Error Handler
Func _INetSmtpMailCom_ErrObjInit($bParam = Default)
    Local Static $oINetSmtpMailCom_Error = Default
    If $bParam == 'CleanUp' And $oINetSmtpMailCom_Error <> Default Then
        $oINetSmtpMailCom_Error = ''
        Return $oINetSmtpMailCom_Error
    EndIf
    If $oINetSmtpMailCom_Error = Default Then
        $oINetSmtpMailCom_Error = ObjEvent("AutoIt.Error", "_INetSmtpMailCom_ErrFunc")
    EndIf
    Return $oINetSmtpMailCom_Error
EndFunc   ;==>_INetSmtpMailCom_ErrObjInit

Func _INetSmtpMailCom_ErrObjCleanUp()
    _INetSmtpMailCom_ErrObjInit('CleanUp')
EndFunc   ;==>_INetSmtpMailCom_ErrObjCleanUp

Func _INetSmtpMailCom_ErrHexNumber($vData = Default)
    Local Static $vReturn = 0
    If $vData <> Default Then $vReturn = $vData
    Return $vReturn
EndFunc   ;==>_INetSmtpMailCom_ErrHexNumber

Func _INetSmtpMailCom_ErrDescription($sData = Default)
    Local Static $sReturn = ''
    If $sData <> Default Then $sReturn = $sData
    Return $sReturn
EndFunc   ;==>_INetSmtpMailCom_ErrDescription

Func _INetSmtpMailCom_ErrScriptLine($iData = Default)
    Local Static $iReturn = ''
    If $iData <> Default Then $iReturn = $iData
    Return $iReturn
EndFunc   ;==>_INetSmtpMailCom_ErrScriptLine

Func _INetSmtpMailCom_ErrFunc()
    _INetSmtpMailCom_ErrObjInit()
    _INetSmtpMailCom_ErrHexNumber(Hex(_INetSmtpMailCom_ErrObjInit().number, 8))
    _INetSmtpMailCom_ErrDescription(StringStripWS(_INetSmtpMailCom_ErrObjInit().description, 3))
    _INetSmtpMailCom_ErrScriptLine(_INetSmtpMailCom_ErrObjInit().ScriptLine)
    SetError(1) ; something to check for when this function returns
    Return
EndFunc   ;==>_INetSmtpMailCom_ErrFunc

#EndRegion UDF Functions

Change "youremail@gmail.com" for your email account

The password for your password andf the receiver.

Anyway you have to set your gmail account to let the less safe apps to send mails with it

Edited by Qwerty212
I missed one function's name
1 person likes this

Share this post


Link to post
Share on other sites

yeah, this is working.

Thank you very much!!!

Share this post


Link to post
Share on other sites

#10 ·  Posted

You're welcome. Maybe you should edit your post tittle with a [SOLVED] ;)

Share this post


Link to post
Share on other sites

#11 ·  Posted

I tried the same script on computer from my work and i get the following error:

sdsds.png

At home is working, but I need to get it to work from computer from my job.

Share this post


Link to post
Share on other sites

#12 ·  Posted

With the same email accounts that work fin from your home?

Share this post


Link to post
Share on other sites

#13 ·  Posted

yes, I really dont understand what happens

 

Share this post


Link to post
Share on other sites

#14 ·  Posted

My guess would be that your company is either using a proxy without support for this specific port or a Firewall blocking the traffic.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#15 ·  Posted

I used sendsmtp, a third party app but the problem is that the body of a mail is in rich text format, and now i must search for a solution to add data from $variables to the rich text lines 

Share this post


Link to post
Share on other sites

#16 ·  Posted

No idea what this means or if this is an answer to the last statement/question, or is this a total different question?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#17 ·  Posted

I can send mails now but using third party app. The body of the mail should be in rich text format.

Now I am looking for a solution to add data from autoit to rtf files

Share this post


Link to post
Share on other sites

#18 ·  Posted

bro,what are  all the servers  required for sending gmail via autoit script ,i am a beginner in autoit.

 

Share this post


Link to post
Share on other sites

#19 ·  Posted

No idea what you are asking.
What exactly is your question about the servers that isn't clear in the shown examples in the original thread or this thread?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

@Qwerty212

Worked first time :)

Windows 10. Nice.  Put this in the Example Scripts?

 

By way of feedback (not error report) I got the following:

Return-Path: <myaccount@gmail.com>
Delivered-To: niclas@somewhere.com
Received: from lemans.websitewelcome.com
                by lemans.websitewelcome.com (Dovecot) with LMTP id YRozIMdMIVr7egsA4p+ctw
                for <niclas@somewhere.com>; Fri, 01 Dec 2017 06:36:23 -0600
Return-path: <myaccount@gmail.com>
Envelope-to: niclas@somewhere.com
Delivery-date: Fri, 01 Dec 2017 06:36:23 -0600
Received: from mail-wm0-f52.google.com ([74.125.82.52]:45365)
                by lemans.websitewelcome.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128)
                (Exim 4.89)
                (envelope-from <myaccount@gmail.com>)
                id 1eKkYJ-003AD4-5m
                for niclas@somewhere.com; Fri, 01 Dec 2017 06:36:23 -0600
Received: by mail-wm0-f52.google.com with SMTP id 9so3250126wme.4
        for <niclas@somewhere.com>; Fri, 01 Dec 2017 04:36:18 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:thread-index:thread-topic:to:subject:date:message-id
         :mime-version:content-class:importance:priority;
        bh=sFx0F2tJvnYH5ZOV0E/5p9BFG+Q4uPEATrMR8aTwsNU=;
        b=YTVZQrfDPx83P7ph7ABOcNDv1rITG4VHJBxg8ZDusc3Uki6B/QQEUZTcsmuj1IYg1T
         UORjzsdzty2I4de5dqC/fd8JcjUDPSCMvdltMMeDD/jmtwA1sVd4uhVebTAb0gKNctlh
         KomGYO7EQDzGF7l4ytITZ4sAwY6CAmKqhA85wQ8XqJSAEsHzEF2EZx5vLgb8G61nBo28
         qKkHo636lx/FwFEtMesvkA4q3zknDDw2BJbTc/QBeedVfwPWDDmvp40u6PisB3dovGeC
         CG/TdrazbEa1pVM3sdILyr0JdWNjukoi2p6schIIyslwIAvb7gBLw0qDOfyUlnxiPJWr
         09ig==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:thread-index:thread-topic:to:subject:date
         :message-id:mime-version:content-class:importance:priority;
        bh=sFx0F2tJvnYH5ZOV0E/5p9BFG+Q4uPEATrMR8aTwsNU=;
        b=Z0s6xRl832vIRVi8J2EdhjhGR9Z77gSpVyRzuKNUyV7H969/zd5nhCvQG/tbtFD5N9
         2G8dg1I/6nmJ56ga3ydyVpzRTpEy4aXe+/k9udE8sKxEtFv5/84pT25//SlwqZzG/AcH
         33C+PstXiUBzraCi0ZLg/uwEj9mITqdX/Zo0Vmd7eED3+5nja2VP8i73xPX/80g/QHoI
         J7vC9bm99OesPA8iv721geR3XPAZyqKt3M7mRSzDysPgRhq8rYbaF01TjEGX0fn5Px0F
         cXcRnWiwL8TGex5S5HTuq7H/FvlR0eEL3kdzTwnycXYDB92B7Ojb4zu+i2gqP3q4tenR
         xAlw==
X-Gm-Message-State: AKGB3mKSDZInBJeGvZA+TlXrSscbFLMDonzUP6T3Uqu2AuCPbm2cVjiY
                d7ZdOl+TdzUTU+kEhWez88TuCw==
X-Google-Smtp-Source: AGs4zMaHSxhCCXJTofPS0ltpSibqiiwRw/TTFu82EVJEVDVTQMpZ2Ho6UVoG9fNANgldLTN6Ek67DA==
X-Received: by 10.28.71.76 with SMTP id u73mr1053399wma.77.1512131771671;
        Fri, 01 Dec 2017 04:36:11 -0800 (PST)
Received: from MyNameWin10 (169-0-230-172.ip.afrihost.co.za. [169.0.230.172])
        by smtp.gmail.com with ESMTPSA id 73sm960220wmb.46.2017.12.01.04.36.10
        for <niclas@somewhere.com>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Fri, 01 Dec 2017 04:36:11 -0800 (PST)
From: MyName <myaccount@gmail.com>
X-Google-Original-From: "MyName" <MyName@somewhere.com>
thread-index: AdNqoPZ8EqtDqfJATayuXqxiJ+2rUA==
Thread-Topic: testing gmail sending 123
To: <niclas@somewhere.com>
Subject: testing gmail sending 123
Date: Fri, 1 Dec 2017 14:36:08 +0200
Message-ID: <C37E7A5165F24C95AB76150497FF15D1@MyNameWin10>
MIME-Version: 1.0
Content-Type: multipart/alternative;
                boundary="----=_NextPart_000_0002_01D36AB1.BA08A240"
X-Mailer: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: Normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE
X-Spam-Status: No, score=-1.6
X-Spam-Score: -15
X-Spam-Bar: -
X-Spam-Flag: NO
X-EsetId: 37303A29AA6B816C607D67

These lines are important:

From: MyName <myaccount@gmail.com>
X-Google-Original-From: "MyName" <MyName@somewhere.com>

I set the script to send from myname@somewhere account, but Outlook (the destination client) showed the "username" field

Local $sFromAddress = "myname@somewhere.com" ; address from where the mail should come
Local $sUsername = "myaccount@gmail.com" ; username for the account used from where the mail gets sent - REQUIRED

Outlook displays From "MyName (myaccount@gmail.com)" in stead of the expected "MyName (myname@somewhere.com)"

Good job :)

Skysnake

Edited by Skysnake

Skysnake

Why is the snake in the sky?

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