How to hide email address

Asked

Viewed 453 times

1

I’m making an algorithm that sends emails, I’m able to send emails normally, but I wish I could hide the email address of the person sending to the recipient.

Obs: when I say hide the email address, I mean the email header, in which the name of the sender appears and the email address between '<>'. I would like to hide the address who comes within the signs of minor and major.

Code C# :

    public HttpResponseMessage SendMail()
    {
        try
        {
            MailMessage _mailMessage = new MailMessage();

            _mailMessage.From = new MailAddress("emailRemetente", "nomeRemetente");

            _mailMessage.CC.Add(emailDestinatario);
            _mailMessage.Subject = "Título do email";
            _mailMessage.IsBodyHtml = true;
            _mailMessage.Body = "Corpo do email HTML";


            SmtpClient _smtpClient = new SmtpClient("smtpclient", Convert.ToInt32(porta));

            _smtpClient.UseDefaultCredentials = false;
            _smtpClient.Credentials = new NetworkCredential("emailRemetente", "senhaRemetente");

            _smtpClient.EnableSsl = true;

            _smtpClient.Send(_mailMessage);

            return Request.CreateResponse(HttpStatusCode.OK, true);
        }
        catch (Exception ex)
        {
            return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
        }
    }
}

I read this link : https://docs.microsoft.com/pt-br/dotnet/api/system.net.mail.mailmessage.bcc?view=netframework-4.8 but I didn’t quite understand.

  • He just tried to pass a string.Empty or repeat the email address in the display name? Are you actually referring to the sending address to which the receiver would respond? Last question, why?

  • @Leandro Angelo Not because I want a name to appear that I will determine.

  • @Leandro Angelo answer to the second question: Yes, I am referring to the email address where the recipient would reply.

  • @Leandro Angelo answer to the last question: Why did my boss ask :)

  • 1

    Ask him if he’s ever received an e-mail with no sender.

  • 1

    This link that you put as example does not cover what you want, it serves for when for example you send email to two people and they do not see that it was for both, as Leandro Angelo said, it is not possible to send an email without identification

  • @Lucas Miranda OK, thank you.

Show 2 more comments

1 answer

0


Instead of using the CC method, use Bcc, it is the CCO (With Hidden Copy) field in English.

In practice:

instead of using the _mailMessage.CC.Add(Email address)

use the _mailMessage.Bcc.Add(Email address).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.