How to change display name in gmail (CDO)

How to change display name in gmail (CDO)

Postby dutch » Thu Dec 14, 2017 5: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: Select all  Expand view
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 19.01 / 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)
User avatar
dutch
 
Posts: 1535
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How to change display name in gmail (CDO)

Postby Enrico Maria Giordano » Thu Dec 14, 2017 9:47 am

Try

Code: Select all  Expand view
:From := ["] + cDisplay + ["] + " <" + cReply + ">"


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8245
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to change display name in gmail (CDO)

Postby dutch » Thu Dec 14, 2017 9: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: Select all  Expand view
:From := ["] + cDisplay + ["] + " <" + cReply + ">"


EMG
Regards,
Dutch

FWH 19.01 / 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)
User avatar
dutch
 
Posts: 1535
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How to change display name in gmail (CDO)

Postby dutch » 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: Select all  Expand view
:From := ["] + cDisplay + ["] + " <" + cReply + ">"


EMG
Regards,
Dutch

FWH 19.01 / 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)
User avatar
dutch
 
Posts: 1535
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How to change display name in gmail (CDO)

Postby Enrico Maria Giordano » Thu Dec 14, 2017 10:17 am

Put

Code: Select all  Expand view
? :cFrom


just after that line and report back.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8245
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to change display name in gmail (CDO)

Postby karinha » Thu Dec 14, 2017 4:57 pm

Maybe:

Code: Select all  Expand view

   hb_default( @cFrom    , "<from@example.net>" )
 


Regards.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7154
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: How to change display name in gmail (CDO)

Postby dutch » Sat Dec 16, 2017 4: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: Select all  Expand view
? :cFrom


just after that line and report back.

EMG
Regards,
Dutch

FWH 19.01 / 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)
User avatar
dutch
 
Posts: 1535
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How to change display name in gmail (CDO)

Postby dutch » Sat Dec 16, 2017 4:39 am

Dear karinha,

Where do I define it?
karinha wrote:Maybe:

Code: Select all  Expand view

   hb_default( @cFrom    , "<from@example.net>" )
 


Regards.
Regards,
Dutch

FWH 19.01 / 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)
User avatar
dutch
 
Posts: 1535
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 16 guests