B4J Question B4J send email, question about email sender ...

Pietro Pancino

Member
Licensed User
Longtime User
Hi all!
I work on a specific app that send mail to customers.
Every thing is working fine, but I just wonder il there is à way to hide the real email like in the first line (in picture), and put a nickname like Linkedin...
1764783712241.png

I send the mail like this:
String definition:
dim from_mail as string = "[email protected]
smtp.Sender=from_mail
Maybe there is a way to encode the email string address like:
String definition:
dim from_mail as string = "[email protected] [The Sender]"
In order to have The sender display in outlook for example instead of [email protected]

It's not a big deal, but it's more informative for the person receiving the mail...

If anyone have an idea!

;-)
 

Attachments

  • 1764782613055.png
    1764782613055.png
    29.7 KB · Views: 11

aeric

Expert
Licensed User
Longtime User
How about?
B4X:
Dim from_mail As String = "The Sender <[email protected]>"

 
Last edited:
Upvote 0

Pietro Pancino

Member
Licensed User
Longtime User
Thanks to you Aeric and DonManfred!!!!

After one hour of tests I have found the solution :
When you send the mail, you have to make the difference beetween Username of smpt.initialize() versus email.Mailfrom and smtp.sender.
The good code is:
the good one:
    dim smtp as smtp
    dim user_name as string = "[email protected]"    
    dim mail_to as string = "[email protected]"

    'init of smtp
    smtp.Initialize(smtp.site.com,25 ,user_name , "1234", "SMTP")
    
'  init  the mail with alias  ' as you had recommended !!!
   Dim the_mail_from As String = "Alias name <" & user_name & ">"  
'   or It's works too :-)
'   Dim the_mail_from As String = $""Alias name""$& " <" & user_name & ">"
 
    smtp.MailFrom = the_mail_from
    smtp.Sender = the_mail_from
    smtp.To.Add(mail_to)
    .....
    smtp.Send

During my firts tests, I was setting then Username = "nick name <[email protected]>", it was wrong, the Username of smtp have to be the real mail, and the smtp.sender and smpt.MailFrom the Email formated with the nick name... in fact it's logical!!! ... ohhhhh ! I'm too old for this job🤪

Many thanks to you to bring me on the good way!! 😉
 
Upvote 0
Top