Jose Retana
Jose Retana

Reputation: 59

Error sending an Email MVC

I'm trying to send an email from my MVC application, but always when I tried to send it I get this error message "Could not find a part of the path 'C:\Temp\67088830-4abc-41c6-afbe-6856bb817889.eml'." at this line

                    smtp.Send(mail);

Any idea or suggestion on how to solve this error...

also this is my code to send it.

                    MailMessage mail = new MailMessage();
                    mail.To.Add(ConfigurationManager.AppSettings["To"]);
                    mail.From = new MailAddress(ConfigurationManager.AppSettings["From"]);
                    mail.Subject = ConfigurationManager.AppSettings["Subject"];
                    string Body = "Test";
                    mail.Body = Body;
                    mail.IsBodyHtml = true;
                    SmtpClient smtp = new SmtpClient();
                    smtp.Host = ConfigurationManager.AppSettings["Host"];
                    smtp.Port = Convert.ToInt32(ConfigurationManager.AppSettings["Port"]);
                    smtp.UseDefaultCredentials = false;
                    smtp.Credentials = new System.Net.NetworkCredential
                   (ConfigurationManager.AppSettings["User"], ConfigurationManager.AppSettings["Pass"]);
                    smtp.EnableSsl = false;
                    smtp.Send(mail);

Upvotes: 1

Views: 1281

Answers (1)

COLD TOLD
COLD TOLD

Reputation: 13569

try setting in your webconfig or in your file the smtp delivery method to network

<smtp deliveryMethod="Network">

Upvotes: 3

Related Questions