Asp.net email question

Collapse

Unconfigured Ad Widget

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • websitebuilder
    Junior Member
    • Feb 2005
    • 1

    Asp.net email question

    Hi,

    Can anybody update me how to send emails using Asp.net?

  • Nici
    Member
    • Sep 2004
    • 31

    #2
    Hi,

    Here we go...

    Code:
    'Create an instance of the MailMessage class
    Dim objMM as New MailMessage();
    
    'Set the properties
    
    'Provide the recipient address
    objMM.To = "recipient@someone.com"
    
    'Provide your address
    objMM.From = "myaddress@mydomain.com"
    
    'If you want to CC this email to someone then provide it over here
    objMM.Cc = "someone@someaddress.com"
    
    'If you want to BCC this email to someone then provide it over here
    objMM.Bcc = "someone2@someaddress2.com"
    
    'Send the email in text format
    '(to send HTML format, change MailFormat.Text to MailFormat.Html)
    objMM.BodyFormat = MailFormat.Text
    
    'Set the priority - options (High, Low, and Normal)
    objMM.Priority = MailPriority.Normal
    
    'Set the subject
    objMM.Subject = "Hello there!"
    
    'Set the body
    objMM.Body = "Hi, How are you doing?"
    
    'Now, to send the message, use the Send method of the SmtpMail class
    SmtpMail.Send(objMM)
    Make sure that you import the System.Web.Mail namespace in your ASP.NET Web page in order to be able to utilize the above code:
    <% @Import Namespace="System.Web.Mail" %>.

    Hope this helps

    Nici

    Last edited by admin; 08-17-2015, 09:26 AM.

    Comment

    Working...
    X