C# Choose Email Box when sending

Asked

Viewed 86 times

0

I was wondering if there is any way to send emails to other inboxes, for example gmail

inserir a descrição da imagem aqui

At the moment my code for sending emails is this:

using (var smtpClient = new SmtpClient(WebConfigurationManager.AppSettings["smtpHost"], 587))
{
     smtpClient.Credentials = new NetworkCredential(WebConfigurationManager.AppSettings["smtpClient"],
                                                    WebConfigurationManager.AppSettings["smtpClientPassword"]);
     smtpClient.EnableSsl = true;

     smtpClient.SendCompleted += (s, e) =>
     {
        smtpClient.Dispose();
        ((MailMessage)e.UserState).Dispose();
     };

     await smtpClient.SendMailAsync(model.GetMessage());
}

Is there any class, property in the client, anything I can do to achieve this goal?

  • Is the goal to send an email to a gmail account? If so, then it is to use that code you have, changing the recipient in the object of the message. ps: you’re doing it in MVC, right?

  • @Renatoafonso The goal is : Instead of sending to inbox, send to Updates, or any other.

  • By code, I think it has no form. You need to set up in your own email box a rule to redirect emails with a certain format to that specific area.

  • @Renatoafonso have any idea how to do this?

  • If it’s gmail, just go to the settings, and you have a filter and address option there, click to create a new filter, set the rules by which you want to capture the type of email you want, and then set the action (where you want to send that email)

No answers

Browser other questions tagged

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