AuthorQuestion
How to send mail in C# without attachment.
Posted on: 13 Dec 2012
This s my coding... i cant send mail by using this code. plz help me....


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Mail;
using System.Net;


public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
    }
    public void sendmail(string from, string to, string subject, string body)
    {
        MailMessage mail = new MailMessage();
        mail.From = from;
        mail.To = to;
        mail.Subject = subject;
        mail.Body = body;
        mail.Priority = MailPriority.High;
        mail.BodyFormat = MailFormat.Text;
        SmtpMail.SmtpServer = "192.168.5,11";
        SmtpMail.Send(mail);
    }
}


[ + ]
AuthorReply
Re: How to send mail in C# without attachment.
Posted on: 13 Dec 2012  
Our Recommended Solutions
If this post helps you mark it as answer
Thanks

Re: How to send mail in C# without attachment.
Posted on: 13 Dec 2012  
Saranya,

This link may be helpful for you:

http://www.c-sharpcorner.com/UploadFile/dchoksi/SendingMail02132007002923AM/SendingMail.aspx

Rohatash
Re: How to send mail in C# without attachment.
Posted on: 19 Dec 2012  
follow this code to send mail with attachment
http://csharp.net-informations.com/communications/csharp-email-attachment.htm

arjun
  • 0
  • 0
Re: How to send mail in C# without attachment.
Posted on: 19 Dec 2012  
hi,

create a button and use this code...i think it will usefull to u



protected void
Button3_Click(object sender, EventArgs e)



    {



     



 



        String to = "Tomailid@gmail.com";



        SmtpClient SmtpServer = new
SmtpClient();



String message="your message in body";



       
SmtpServer.Credentials = new System.Net.NetworkCredential("yourmailid@gmail.com
"
, "password");



       
SmtpServer.Port = 587;



       
SmtpServer.Host = "smtp.gmail.com";



       
SmtpServer.EnableSsl = true;



        MailMessage mail = new
MailMessage();



       



        try



        {



 



           
mail.From = new MailAddress("yourmailid@gmail.com", "Subject", System.Text.Encoding.UTF8);



           // mail.To.Add(new MailAddress(to));



           
mail.To.Add(new MailAddress(t));



            // mail.Subject = subject;



           
mail.Body = message;



           



           
mail.IsBodyHtml = true;



           
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;



           
SmtpServer.Send(mail);



 



        }



        catch (Exception
err)



        {



           



        }



    }





SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts