Send email without it appearing in the mailbox

Asked

Viewed 101 times

3

I don’t want those items sent in the real estate email.

            string emailOrigem = imobiliaria.Email;
            string password = imobiliaria.Senha;
            string html = getBody(dados); //aqui serve pra formata o html

            if (!string.IsNullOrEmpty(html))
            {
                MailMessage msg = new MailMessage();
                msg.Subject = dados.Assunto;
                msg.From = new MailAddress(emailOrigem);

                msg.IsBodyHtml = true;
                msg.Body = html;

                if (dados.Modelo.Contains("indicar"))
                {
                    EmailTemplate plate = (EmailTemplate)dados;
                    bool temEmail = !string.IsNullOrEmpty((dados as EmailTemplate).EmailIndicado);
                    if (temEmail)
                    {
                        msg.To.Add(plate.EmailIndicado);
                    }
                }
                else
                {
                    msg.To.Add(new MailAddress(Email da imobiliaria aq));
                }

                SmtpClient smtp = new SmtpClient();
                //smtp.Host = "smtp.gmail.com";
                smtp.Host = "smtp-mail.outlook.com";
                smtp.Port = 587;
                smtp.UseDefaultCredentials = false;
                smtp.EnableSsl = true;
                NetworkCredential nc = new NetworkCredential(emailOrigem, password);
                smtp.Credentials = nc;
                smtp.Send(msg);
  • You have no control over it. You may even have some Google API that allows you to manipulate the boxes, but it’s another technology.

  • So you’re gonna show up anyway?... Blz Vlww guy

  • This way it goes. Only with Apis could you manipulate the boxes, yet I’m not saying that they allow it, only that it’s a possibility. But if you are going to use the API I find it unlikely that you need to use the mail server.

  • It was just a little uncomfortable, so if I’m not fooled, they write an email for it. Anyway. vlw man

1 answer

4


The technology being used is to connect to an SMTP server and send the message. Nothing more. There is no way to control how the provider will manipulate the messages.

In the case of Google I know you have an API to do this. But it’s something else entirely. And if you are to use it you should probably do all the process for it and not by the SMTP server.

Example API command to send the message to the trash.

Browser other questions tagged

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