1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Sending E-Mails with ASP Pages

Discussion in 'ASP' started by pradeep, May 1, 2005.

  1. pradeep

    pradeep Team Leader

    Sending an email with asp is fairly easy, all you need is CDONTS (Collaboration Data Objects for NT Server, installed with IIS), or a special component like SMTPmail by SoftArtisans, or AspEmail ( free ) by Persits Software Inc (there are more available).

    In this article I'll show how to send emails with CDO, because it's available to everyone and
    components work in a very similar way. First we have to create instance of the NewMail object.

    	Option Explicit
    	Dim objCDOMail
    	Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
    The methods and property's of this object are very obvious.

    	objCDOMail.To = "somebody@somewhere.com"   'the destination
    	objCDOMail.From = "me@mydomain.com"   'the sender
    	objCDOMail.cc = "info@mydomain.com"   'carbon copy
    	Dim txtBody
    	txtBody = "This email has been sent by an asp script"
    	objCDOMail.Subject = "CDONTS"   'the subject
    	objCDOMail.Body = txtBody   'the body
    	objCDOMail.Send   'fire off the email
    So far it has been pretty easy, hasn't it? There's more.

    	objCDOMail.AttachFile("c:\wwwroot\mysite\" & _
    		"MyAttachement.doc", "pricelist.doc")
    	objCDOMail.Importance = 1
    The first rule defines an attachment ("PATH\TO\FILE", filename_that_appears)
    The second rule sends a blind carbon copy The third rule specifies the message's importance

    0 -> low
    1 -> default
    2 -> high

    Thats it, I hope this article has been useful and i hope that now you will feel confident sending automated newsletters, confirmation emails and so on.
  2. shabbir

    shabbir Administrator Staff Member

    Nice and simple way to send an email.
  3. Bhavin

    Bhavin New Member

    i had used the code to send mail but the mail are goes to the bulk folder of the user.
    Please tell me what will i do so the mail is goes to the inbox not to the bulk folder.
  4. pradeep

    pradeep Team Leader

    The mail goes to the Bulk Folder because the your mail provider detected it as spam. If the mail does not come from a listed Mail Server, it is usually considered as spam.
    check these links, if your IP is present in their database, some servers might not even accept the mail.
    So, one thing you can do is get your SMTP server registered there.
  5. hasmukh

    hasmukh New Member

    Good Info Thanks

    :) HASMUKH :)
  6. himali

    himali New Member

    is there any way i can add headers in email?

    im using cdo object but i can't find a clue about how to add header

    for example:

    Microsoft Mail Internet Headers Version 2.0

    Received: from (IP) ([IP]) by SERVERNAME ([IP]) with Microsoft Exchange Server HTTP-DAV ;

    Wed, 10 Sep 2008 16:02:39 +0000

    User-Agent: Microsoft-Entourage/

    Date: Wed, 10 Sep 2008 17:00:29 +0100

    Subject: Test for agent



    Message-ID: <C4EDADAD.53FB%SENDER@SOMEONE.co.uk>

    Thread-Topic: Test for agent

    Thread-Index: AckTXliJls/D+H9REd2DXwAX8sdIJQ==

    X-Priority: 1

    Mime-version: 1.0

    Content-type: text/plain;


    Content-transfer-encoding: 7bit
  7. pradeep

    pradeep Team Leader

Share This Page