Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to compose email using .net

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 174
    Comment on it

    Hello Reader's if you are new to asp.net and looking to see how email is send then this blog is helpful to you. Sending the email in asp is comparatively similar with php just you have to follow the coding syntax.

    <%
    Set myMail=CreateObject("CDO.Message")
    myMail.Subject="testing the email working"
    myMail.From="setyouremail@abc.com"
    myMail.To="sender@abc.com"
    myMail.Bcc="bcc@somedomain.com"
    myMail.Cc="cc@somedomain.com"
    myMail.TextBody="Hi this is a testing of email using asp."
    myMail.Send
    set myMail=nothing
    %>

    In the code above you can see the mail by CDO. CDOSYS is a built-in component in ASP. This takes the action for sending the emails. This is same as php mail function.CDO stands for Collaboration Data Object.
    To use the components of messaging components Microsoft has develope this.

    This is a simple mail which will run quick and works well.

    Now we will sending a text e-mail with an Attachment:

    <%
    Set myMail=CreateObject("CDO.Message")
    myMail.Subject="Sending email with CDO"
    myMail.From="mymail@mydomain.com"
    myMail.To="someone@somedomain.com"
    myMail.TextBody="This is a message."
    myMail.AddAttachment "c:\mydocuments\test.txt"
    myMail.Send
    set myMail=nothing
    %>

    Also you can send a text e-mail using a remote server, and the setting will be like this:-

    <%
    Set myMail=CreateObject("CDO.Message")
    myMail.Subject="Sending email with CDO"
    myMail.From="your@mydomain.com"
    myMail.To="sender@somedomain.com"
    myMail.TextBody="This is a message."
    myMail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
    'Name or IP of remote SMTP server
    myMail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.server.com"
    'Server port
    myMail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
    myMail.Configuration.Fields.Update
    myMail.Send
    set myMail=nothing
    %>

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: