13
Answers

how can i send email from hosting using my asp.net website

as shown in titlte how can i send email ffrom hosting  email
i was send using stmp.gmail.com
but now i have domin
so what i should to do 
Answers (13)
0
Thiruppathi R

Thiruppathi R

NA 8.7k 371.2k 7y
You refer my article 
 
http://www.c-sharpcorner.com/article/learn-web-api-using-wpf-webforms-and-xamarin/ 
Accepted
1
Nilesh Shah

Nilesh Shah

NA 22.3k 214.9k 7y
I see you repeated the same question twice.
 
Please delete one of them.
 
thanks
0
Rajeesh Menoth

Rajeesh Menoth

NA 24.7k 629.4k 7y
Hi,
 
You can check my blog !!
 
http://www.c-sharpcorner.com/Blogs/49373/smtp-server-requires-a-secure-connection.aspx
 
http://www.c-sharpcorner.com/UploadFile/2a6dc5/how-to-send-a-email-using-Asp-Net-C-Sharp/ 
0
Thiruppathi R

Thiruppathi R

NA 8.7k 371.2k 7y
You can chnage  from 
smtp.Port = 80; to
smtp.Port = 587; 
 
if there any exception ? 
 
 
0
Carnation Flowers

Carnation Flowers

NA 258 9k 7y
 now i tried the same code you sent and configrate in webconfig
but still not working??? 
<appSettings>
<add key="Port" value="587"/>
<add key="Host" value="smtp.gmail.com" />
<add key="MailFrom" value="cantion@gmail.com" />
<add key="password" value="123" />
<add key="EnableSsl" value="True" />
</appSettings>
 ------
 
using (System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage("carntion@gmail.com", txtemail.Value))
{
mm.Subject = "Account Activation ";
string body = "Hello " + txtemail.Value + ",";
body += "<br /><br />Please click the following link to activate your account";
body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("createAccount.aspx", "userActivation.aspx?ActivationCode=" + activationCode) + "'> Welcome To On Call App Please Click here to activate your account.</a>";
body += "<br /><br />Thanks";
mm.Body = body;
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.EnableSsl = true;
NetworkCredential NetworkCred = new NetworkCredential("carntion@gmail.com", "123");
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 80;
smtp.Send(mm);
}
 
0
Thiruppathi R

Thiruppathi R

NA 8.7k 371.2k 7y
yes, this basci setup for smtp.but there i am using gmail.
 
if you work different domain,you can ask them what is that "port number" & "host address"
 
 it will comes like 
 
<add key="Port" value="25"/>
<add key="Host" value="mail.xxxx.com" />
 
 
0
Carnation Flowers

Carnation Flowers

NA 258 9k 7y
sir 
i want to send the email from my domin hosting
will it work when i use gmail
i m sorry i littel beginner
and realy need help 
0
Thiruppathi R

Thiruppathi R

NA 8.7k 371.2k 7y
Oh yes i have configure in web.config file 
 
  • <appSettings>
  • <add key="Port" value="587"/>
  • <add key="Host" value="smtp.gmail.com" />
  • <add key="MailFrom" value="XXXXX@gmail.com" />
  • <add key="password" value="XXXX" />
  • <add key="EnableSsl" value="True" />
  • </appSettings>
  •  
    0
    Carnation Flowers

    Carnation Flowers

    NA 258 9k 7y
    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
    SmtpClient smtpServer = new SmtpClient();
    string password = ConfigurationManager.AppSettings["12312z"];
    mail.From = new MailAddress(ConfigurationManager.AppSettings["am@carh.com"]);
    string[] toRecipients = vm.ToRecipients.Split(',');
    foreach (string toRecipient in toRecipients)
    {
    if (!string.IsNullOrEmpty(toRecipient))
    mail.To.Add(new MailAddress(toRecipient));
    }
    mail.Subject = vm.Subject;
    mail.Body = vm.Body;
    vm.FromRecipients = ConfigurationManager.AppSettings["MailFrom"];
    smtpServer.Host = ConfigurationManager.AppSettings["Host"];
    smtpServer.Port = int.Parse(ConfigurationManager.AppSettings["Port"]);
    smtpServer.DeliveryMethod = SmtpDeliveryMethod.Network;
    smtpServer.EnableSsl = bool.Parse(ConfigurationManager.AppSettings["EnableSsl"]);
    smtpServer.Timeout = 100000;
    smtpServer.Credentials = new System.Net.NetworkCredential(vm.FromRecipients, password);
    smtpServer.Send(mail);
     
     
     
     
     
     
    please show me how to fil them
    host mean the Domani or web hosting
    i get on WebsitePanle.com 
    0
    Thiruppathi R

    Thiruppathi R

    NA 8.7k 371.2k 7y
    "vm" is  variable class.once you refer that article 
     
    http://www.c-sharpcorner.com/article/learn-web-api-using-wpf-webforms-and-xamarin/
     
    main core is sending mail using Gmail domine only 
     
    0
    Carnation Flowers

    Carnation Flowers

    NA 258 9k 7y
    dear sir
    whats vm??
    its not declared 
    0
    Thiruppathi R

    Thiruppathi R

    NA 8.7k 371.2k 7y
    MailMessage mail = new MailMessage();
    SmtpClient smtpServer = new SmtpClient();
    string password = ConfigurationManager.AppSettings["password"];
    mail.From = new MailAddress(ConfigurationManager.AppSettings["MailFrom"]);
    string[] toRecipients = vm.ToRecipients.Split(',');
    foreach (string toRecipient in toRecipients)
    {
    if (!string.IsNullOrEmpty(toRecipient))
    mail.To.Add(new MailAddress(toRecipient));
    }
    mail.Subject = vm.Subject;
    mail.Body = vm.Body;
    vm.FromRecipients = ConfigurationManager.AppSettings["MailFrom"];
    smtpServer.Host = ConfigurationManager.AppSettings["Host"];
    smtpServer.Port = int.Parse(ConfigurationManager.AppSettings["Port"]);
    smtpServer.DeliveryMethod = SmtpDeliveryMethod.Network;
    smtpServer.EnableSsl = bool.Parse(ConfigurationManager.AppSettings["EnableSsl"]);
    smtpServer.Timeout = 100000;
    smtpServer.Credentials = new System.Net.NetworkCredential(vm.FromRecipients, password);
    smtpServer.Send(mail);
    0
    Carnation Flowers

    Carnation Flowers

    NA 258 9k 7y
    ok i will delete one
    but the artical not as i ask
    instead "smtp.gmail.com" what i should write and email doesnt send from hsting but send email on local when i use gmail
    wating answer
    thankyou