Click here to Skip to main content
15,907,281 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want sendig email with asp.net please help me?
Posted
Comments
andy(-RKO) 19-Mar-12 3:09am    
try this :
URL:-
www.codeproject.com/Articles/1684/Sending-Mail-Using-C-via-SMTP

http://www.codeproject.com/Articles/12511/Send-Email-in-ASP-Net-2-0-Feed-back-Form

http://www.codeproject.com/Articles/8280/Sending-Emails-from-C-Application-using-default-SM

Regards
Andy.

Basically, you put the data you need in the Web form and use HTTP request method "post". On server side, you gather the requested data, make a e-mail message our of it and send it using some mail agent (most typically, using SMTP).

First of all, please see:
http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient%28v=vs.90%29.aspx[^]
http://msdn.microsoft.com/en-us/library/system.net.mail.aspx[^].

See also:
Please see:
http://www.asp.net/web-forms/videos/how-do-i/how-do-i-use-aspnet-to-send-email-from-a-web-site[^],
http://forums.asp.net/t/1726545.aspx/1[^].

This topic is too popular. With CodeProject along, you can find plenty of relevant information and code samples:
unable to send mail , it showing the error in below code .[^].

I need to warn you about security in your approach. This is really serious. Please see my past answer:
unable to send mail , it showing the error in below code .[^].

—SA
 
Share this answer
 
try this,

MailAddress mailfrom = new MailAddress ( "frommail@gmail.com" );
MailAddress mailto = new MailAddress ( "tomail@gmail.com" );
MailMessage newmsg = new MailMessage ( mailfrom, mailto );

newmsg.Subject = "Subject of Email";
newmsg.Body = "Body(message) of email";

////For File Attachment, more file can also be attached

//Attachment att = new Attachment ( "G:\\code.txt" );
//newmsg.Attachments.Add ( att );

SmtpClient smtps = new SmtpClient ( "smtp.gmail.com", 587 );
smtps.UseDefaultCredentials = false;
smtps.Credentials = new NetworkCredential ( "urmail@gmail.com", "urpwd" );
smtps.EnableSsl = true;
smtps.Send ( newmsg );
 
Share this answer
 
Have a look :

C#
string configMailID = "aa@abc.com";
string ContactMailID = "bb@abc.com";
 string subject ="Hello";
string mailBody = "HI";
int mailSent = SendMailThroughOutlook(configMailID,ContactMailID,subject,mailBody);


public int SendMailThroughOutlook(string mailFrom,string mailTO,string mailSubject,string mailBody)
        {
            int isMailSent = 0;
            MailMessage message = new MailMessage();           
            try
            {
                message.From = new MailAddress(mailFrom);
                string[] AdminIds = mailTO.Split(',');
                for (int i = 0; i < AdminIds.Length; i++)
                {
                    message.To.Add(new MailAddress(AdminIds[i]));
                }
                if (mailCC.Trim().Length != 0)
                    message.CC.Add(mailCC);

                message.Subject = mailSubject;
                message.Body = mailBody;
                message.IsBodyHtml = true;
                SmtpClient client = new SmtpClient("abc.com", 25);
                
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                Exception ex = new Exception();
                client.Send(message);
                isMailSent = 1;
          
            }
            catch (Exception ex)
            {
                isMailSent = 0;
              
            }
            finally
            {
                message.Dispose();
            }
            return isMailSent;
 
Share this answer
 
v2
 
Share this answer
 
v2
Please refer following url,

Send mail using Google Apps[^]

Hope this may help you...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900