How to send automated email in asp.net?

asp.net Portugal
  • 12 years ago

     Hello:

     

    I need help. I designed in a website page, textboxes for a user to fill certain fields.

     

    After that, by pressing a button, an email should be sent using a certain format.

     

    I manage to find out how to send an email URL= ... mailto:***

     
    However that opens up a email editor like Outlook. However what I really wanted was to send that email from the website page...

     

    Is there any function or whatever that I can give parameters to send email, like  functionX (string email, string title, string text, ..)

     

    How can I achieve this goal?

     

    thank you
     

     



     

  • 12 years ago

    if you want to send automated email,one method you should apply one free mail,and then get its smtp server information.like http://www.163.com, its mail smtp server is smtp.163.com.then you can write a method as follows:

        public  static void  EMailAction(string strSMTPServer,string strFrom, string strTo, string strSubject, string strMessage, string strCC ,string strAttachment,string strUserName,string strPwd)
      {
       MailMessage mm = new MailMessage();
       mm.From = strFrom;
       mm.To = strTo;
       if (strCC != "")
       {
        mm.Cc = strCC;
       }
       mm.BodyFormat = MailFormat.Html;
       mm.BodyEncoding = Encoding.Default;
       mm.Subject = strSubject;
       mm.Body = strMessage;
       if (strAttachment != string.Empty )
       {
        System.Web.Mail.MailAttachment attach = new MailAttachment(strAttachment);
        mm.Attachments.Add(attach) ;
       }
       mm.Priority = MailPriority.High;
       mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
       mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",strUserName );
       mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",strPwd);
       SmtpMail.SmtpServer = strSMTPServer;
       SmtpMail.Send(mm);
       mm = null;
      }

     

    then to call the method,hope it is useful to you

  • 12 years ago
    thank you very much

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“It works on my machine.” - Anonymous