Click here to Skip to main content
12,998,654 members (129,862 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I want know, how to send a mail automatically to other using webservice in asp.net4.0

could u help with coding ...

Posted 9-Jan-12 19:34pm
Updated 9-Jan-12 20:36pm
SAKryukov 10-Jan-12 1:36am
Help with what? What does this "automatically" mean? On what events, where, what's the content. Why, after all?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

look man on a special event you have to to use this code:

            MailMessage mM = new MailMessage();
            mM.From = new MailAddress("");
            mM.Subject = "your subject line will go here";
            //mM.Attachments.Add(new Attachment(@"C:\\attachedfile.jpg"));
            mM.Body = reContactUs.Text;
            mM.IsBodyHtml = true;
            SmtpClient sC = new SmtpClient("");//this is the smtp of hotmail
            //port number for Hot mail
            sC.Port = 25;
            sC.Credentials = new NetworkCredential("your", "password");
            sC.EnableSsl = true;
        catch (Exception ex)
            throw ex;
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

System.Net.Mail namespace in .NET framework helps to send email from MSDN reference at:[^]

Sample code is:
private static void SendEmail(MailAddress fromAddress, MailAddress toAddress, string subject, string body)
    var message = new MailMessage(fromAddress, toAddress)
                          Subject = subject,
                          Body = body
    var client = new SmtpClient("smtpServerName");

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170622.1 | Last Updated 10 Jan 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100