This is the code to send emails, but it returns an error in the try
block:
Protected Zero Page_Old (Object Sender, EventEurges E) {Email Orientity Email = New Email Utility (); E-mail. Email = new mail form (); String body = Email GETEmail template (Server.MapPath ("~ / EmailTemplates"), "test.htm"); EmailMessageToken Tokens = New EmailMessageToken (); Token Tokenname = "$ name $"; Token Tokenwell = "Ricky"; Email messageToken token = new emailMessakeToken (); Tokens.Add (token); //av.LinkedResources.Add(lr); Email.Email.Body = email.ReplaceTokens (body, token); E-mail. E-mail. To Add (new mail address ("sahil4659@gmail.com")); Email.Email.IsBodyHtml = True; Email.Email.fr = New Mail Address ("sahil4659@gmail.com"); Email.Email.Subject = "Hello from bootcamp"; E-mail. SMTP Host = configuration manager App Settings ["SMTPServer"]; Try {email.SMTP.Send (email.Email); Response. Type ("Email Sent!"); } Hold (Exception Pre) {Response.Write (ex.StackTrace); }}
is an error:
on System.Net.Mail.IisPickupDirectory.GetPickupDirectory () on System.Net.Mail.SmtpClient.Send (__Efault Mail message on page_load (object sender, event aRGS) c: \ Users \ Sahil \ Desktop \ Csharp Email Code (2) \ Test Website \ EmailTest.aspx.cs: line 38
) < / Div>
I am reading your mind and assume that you are seeing ... In your web.config, configure your web app to be able to talk to the SMTP server originally. See this thread for more, and system.Net.Mail.SmtpException: IIS can not get pickup directory. Googling around, I will see the references to SMTP configuration that you need in your web configuration, your mail server may need credentials, so you might need something for it:
& lt; System.net & gt; & Lt; MailSettings & gt; & Lt; Smtp from = "fromaddress" & gt; & Lt; Network default credential = "true" host = "smtpservername" port = "smtpserverport" userName = "username" password = "password" /> & Lt; / Smtp & gt; & Lt; / MailSettings & gt; & Lt; /system.net>
Comments
Post a Comment