Go4Expert

Go4Expert (http://www.go4expert.com/)
-   ASP (http://www.go4expert.com/articles/asp-tutorials/)
-   -   Sending E-Mails with ASP Pages (http://www.go4expert.com/articles/sending-e-mails-asp-pages-t286/)

pradeep 1May2005 22:15

Sending E-Mails with ASP Pages
 
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.

Code: ASP

<%
    Option Explicit

    Dim objCDOMail
    Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
%>

The methods and property's of this object are very obvious.

Code: ASP

<%
    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.

Code: ASP

<%
    objCDOMail.AttachFile("c:\wwwroot\mysite\" & _
        "
MyAttachement.doc", "pricelist.doc")
    objCDOMail.Bcc("
blind@mysite.com")
    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

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.

shabbir 2May2005 10:09

Re: Sending E-Mails with ASP Pages
 
Nice and simple way to send an email.

Bhavin 19Oct2005 12:23

Re: Sending E-Mails with ASP Pages
 
hi,
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.

pradeep 19Oct2005 12:37

Re: Sending E-Mails with ASP Pages
 
Hi,
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.
http://dsbl.org/main
http://www.spamhaus.org/xbl/
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.

hasmukh 31Jul2006 09:58

Re: Sending E-Mails with ASP Pages
 
Good Info Thanks


:) HASMUKH :)

himali 22Sep2008 03:42

Re: Sending E-Mails with ASP Pages
 
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/11.4.0.080122

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

Subject: Test for agent

From: SENDER <SENDER@SOMEONE.co.uk>

To: <RECEIVER@SOMEOTHER.com>

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;

charset="US-ASCII"

Content-transfer-encoding: 7bit

pradeep 22Sep2008 10:42

Re: Sending E-Mails with ASP Pages
 
http://help.lockergnome.com/office/h...ict978581.html


All times are GMT +5.5. The time now is 14:03.