FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to change display name in gmail (CDO)
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
How to change display name in gmail (CDO)
Posted: Thu Dec 14, 2017 05:37 AM
Dear All,

I send mail from smpt.gmail.com and the reply name is different from gmail.com account.
Example
-----------
user : dutchez@gmail.com
pass : 12345678
display : EASYFO Hotel
reply : dutchez@easyfohotel.com

Code (fw): Select all Collapse
TRY
  oEmailCfg := CREATEOBJECT( "CDO.Configuration" )
  WITH OBJECT oEmailCfg:Fields
     :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value                 := cSmtp  // "smtp.gmail.com"
     :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value         := iif(lSSL,465,25)
     :Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value              := 2   // Remote SMTP = 2, local = 1
     :Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value       := lAuthen  // .T.
     :Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value                 := lSSL  // .T.
     :Item( "http://schemas.microsoft.com/cdo/configuration/savesentitems" ):Value          := lSave
     :Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value           := cSender  //  "hotel@gmail.com"
     :Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value           := cPass // Password
     :Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value := 20
     :Update()
  END WITH
CATCH oError
    MsgAlert("Could not setting message" + CRLF+ ;
            "Error : " + TRANSFORM(oError:GenCode, NIL) + ";" + CRLF+;
            "SubCode : "  + TRANSFORM(oError:SubCode, NIL) + ";" + CRLF+ ;
            "OSCode : "+ TRANSFORM(oError:OsCode, NIL) + ";" + CRLF +;
            "SubSystem : " + TRANSFORM(oError:SubSystem, NIL) + ";" +CRLF+ ;
            "Message : " + oError:Description )
END

oError:=NIL

cDisplay :=  "EASYFO Hotel"
cReply   := "dutchez@easyfohotel.com"

TRY
    oEmailMsg := CREATEOBJECT ( "CDO.Message" )
    WITH OBJECT oEmailMsg
        :Configuration  := oEmailCfg
        :From               := chr(34)+cDisplay+" "+chr(34)+ "<"+cReply+">" // This will be displayed in the From (The email id does not appear)
        :To                 := cTo   // "customers@hotmail.com"    // <-----   Place your email address
        :Subject            := rtrim(cSubject)  //   "Email Test Message from GMail"
        :ReplyTo            := cReply
        :MDNRequested   := .F.
        if !empty(cAttach)
              :AddAttachment(cAttach)
        end
        :HTMLBody = cHtml
    END WITH
    oEmailMsg:Send()
CATCH oError
    MsgStop("Could not send message" + CRLF+ ;
            "Error : " + TRANSFORM(oError:GenCode, NIL) + CRLF+;
            "SubCode : "  + TRANSFORM(oError:SubCode, NIL) + CRLF+ ;
            "OSCode : "+ TRANSFORM(oError:OsCode, NIL) + CRLF +;
            "SubSystem : " + TRANSFORM(oError:SubSystem, NIL) + CRLF+ ;
            "Message : " + oError:Description )
END


I need to show in mail header as below;

EASYFO Hotel <dutchez@easyfohotel.com>

But it show

EASYFO Hotel <dutchez@gmail.com>

The reply name show correctly ( "dutchez@easyfohotel.com" ), when reply mail.
How can I change email header?
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: How to change display name in gmail (CDO)
Posted: Thu Dec 14, 2017 09:47 AM
Try

Code (fw): Select all Collapse
:From := ["] + cDisplay + ["] + " <" + cReply + ">"


EMG
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How to change display name in gmail (CDO)
Posted: Thu Dec 14, 2017 09:57 AM
Dear EMG,

I try but didn't success. I compile passed, runtime doesn't error but It show CDO.Error Message.
Enrico Maria Giordano wrote:Try

Code (fw): Select all Collapse
:From := ["] + cDisplay + ["] + " <" + cReply + ">"


EMG
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How to change display name in gmail (CDO)
Posted: Thu Dec 14, 2017 10:09 AM
Dear EMG,

Sorry for previous post. You code does not got an error.

It can send mail but the header is the same;
in the <> still show gmail account.

Enrico Maria Giordano wrote:Try

Code (fw): Select all Collapse
:From := ["] + cDisplay + ["] + " <" + cReply + ">"


EMG
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: How to change display name in gmail (CDO)
Posted: Thu Dec 14, 2017 10:17 AM
Put

Code (fw): Select all Collapse
? :cFrom


just after that line and report back.

EMG
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: How to change display name in gmail (CDO)
Posted: Thu Dec 14, 2017 04:57 PM
Maybe:

Code (fw): Select all Collapse
   hb_default( @cFrom    , "<from@example.net>" )


Regards.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How to change display name in gmail (CDO)
Posted: Sat Dec 16, 2017 04:37 AM
Dear EMG,

It is correct "EASYFO Hotel" <dutchez@easyfohotel.com>
but
when it show in Outlook "EASYFO Hotel" <dutchez@gmail.com>
Enrico Maria Giordano wrote:Put

Code (fw): Select all Collapse
? :cFrom


just after that line and report back.

EMG
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How to change display name in gmail (CDO)
Posted: Sat Dec 16, 2017 04:39 AM
Dear karinha,

Where do I define it?
karinha wrote:Maybe:

Code (fw): Select all Collapse
   hb_default( @cFrom    , "<from@example.net>" )


Regards.
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)

Continue the discussion