Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_components thread: Com object to read Mail?


Message #1 by "rich" <shinecello@h...> on Tue, 13 Nov 2001 11:38:59
Hi



I am using SMTP service to retrieve e-mail. I am looking for a COM 

component/ASP script that seperates the .eml file (e.g To, From, Subject, 

Attachments etc. so I can store the e-mail in a database.



I'm sure I found a page on this before, however I can't find it now!



Thanks



Richard
Message #2 by "Bruce J. Pezzlo" <bpezzlo@p...> on Tue, 13 Nov 2001 11:58:59 -0500
You're probably using SMTP to send mail.  (POP for receiving mail).

CDONTS (collaborative data objects) is an ActiveX object that Microsoft

provides for email among other things.



Do a search for "CDONTS SMTP POP" in MSDN, you will come across an

example Johnny Papa and Eric Wilson wrote in 1999 for an artice in

Microsoft Internet Mag.  It shows how to use CDONTS object for both

sending and receiving email. 



You'll also find loads of stuff on CDONTS in general, if you broaden

your search to just "CDONTS".



Bruce





---

Bruce Pezzlo

MCSD & MCDBA

President

PLUM Computer Consulting, Inc.

(617) 266 - 1942 x201

Fax: (617) 267 - 0895

bpezzlo@p...







-----Original Message-----

From: rich [mailto:shinecello@h...]

Sent: Tuesday, November 13, 2001 6:39 AM

To: ASP components

Subject: [asp_components] Com object to read Mail?





Hi



I am using SMTP service to retrieve e-mail. I am looking for a COM

component/ASP script that seperates the .eml file (e.g To, From,

Subject,

Attachments etc. so I can store the e-mail in a database.



I'm sure I found a page on this before, however I can't find it now!



Thanks



Richard






$subst('Email.Unsub')



Message #3 by "Bruce J. Pezzlo" <bpezzlo@p...> on Tue, 13 Nov 2001 12:19:09 -0500
I responded before with CDO (collaborative data objects) as a

suggestion.  You mention eml ... are you using exchange 2000?  If so,

the email is essentially stored by exchange in a database which you may

query as you'd like, without having to extract the stuff and put into

another db which is, as I understand it, your intention ( I can get you

examples of extracting this info with ADO if Exchange 2000 is what your

are using.) 



I'm not sure what your doing, so if CDO doesn't help you ( CDONTS ,

CDOSession ) look for SendMail.ExchangeEMail .  Or, explain where the

eml is coming from (is it simply plain  incoming email, or are the eml

files in some folder you are navigating to using Exchange 2000).



Bruce





---

Bruce Pezzlo

MCSD & MCDBA

President

PLUM Computer Consulting, Inc.

(617) 266 - 1942 x201

Fax: (617) 267 - 0895

bpezzlo@p...





-----Original Message-----

From: rich [mailto:shinecello@h...]

Sent: Tuesday, November 13, 2001 6:39 AM

To: ASP components

Subject: [asp_components] Com object to read Mail?





Hi



I am using SMTP service to retrieve e-mail. I am looking for a COM

component/ASP script that seperates the .eml file (e.g To, From,

Subject,

Attachments etc. so I can store the e-mail in a database.



I'm sure I found a page on this before, however I can't find it now!



Thanks



Richard






$subst('Email.Unsub')



Message #4 by "paul leverell" <leverell@i...> on Wed, 14 Nov 2001 09:16:54 +1100
This is a multi-part message in MIME format.



------=_NextPart_000_0018_01C16CED.1A347920

Content-Type: text/plain;

	charset="iso-8859-1"

Content-Transfer-Encoding: quoted-printable



Rich



CDONTS



Can do this with my limited knowledge, the following script retrieves 

from my smtp gateway an email that has been auto generated using a 

mailto using a cgi script to deliver back to my server. CDONTS looks for 

all messages for SiteAccess and then retrieves them stripping out all 

relevent fields and content. In this case the format of the email 

generated by the CGI script fills in with spaces and then does a LF CR.



The ADO then places the data into an SQL database.



I suppose this is a quick fix but it works for all my automated email 

content what ever the format is.



<% @ LANGUAGE=3D"VBSCRIPT" %>



<%



response.expires=3D0



dim objMail, objSession, objInbox, colMessages, objMessage, iLoop, 

strhitdate, objCon, strSql











Set objCon =3D Server.CreateObject("ADODB.Connection")



objCon.Open 

"DATABASE=3DDinnerparty;DSN=3Ddatabase;UID=3Dveg;PASSWORD=3Dpassword"











Set objSession =3D Createobject("CDONTS.Session")



objSession.LogonSMTP "SiteAccess","SiteAccess@m..."



Set objInbox =3D objSession.Inbox



Set colMessages =3D objInbox.Messages



Response.write "<h2>SiteAccess</h2><br>"



Response.write objInbox.Name & " - " & colMessages.Count & " messages 

<br>"



for iLoop =3D 1 to colMessages.Count



set objMessage =3D colMessages(iLoop)



Response.write "subject =3D " & objMessage.Subject & " Time Sent =3D " & 

objMessage.TimeSent &"<br>"



Response.write "text =3D " & objMessage.text &"<br>"



strhitdate =3D mid(objMessage.text,22,19)



response.write "hitdate =3D " & strhitdate & "<br>"



strSql =3D "Insert into Access (date, AccessType) values('" & strhitdate 

&"','SiteAccess')"



objCon.Execute strSql



objMessage.delete







next



objCon.close



%>









----- Original Message -----

From: "rich" <shinecello@h...>

To: "ASP components" <asp_components@p...>

Sent: Tuesday, November 13, 2001 11:38 AM

Subject: [asp_components] Com object to read Mail?





> Hi

>

> I am using SMTP service to retrieve e-mail. I am looking for a COM

> component/ASP script that seperates the .eml file (e.g To, From, 

Subject,

> Attachments etc. so I can store the e-mail in a database.

>

> I'm sure I found a page on this before, however I can't find it now!

>

> Thanks

>

> Richard

> 



leverell@i...


$subst('Email.Unsub')

>

>






Message #5 by "Bruce J. Pezzlo" <bpezzlo@p...> on Thu, 15 Nov 2001 19:49:45 -0500

(This ended up in newsgroup on new thread, in RE:Exchange because

subject of email was changed by accident)





I have put a code example at the bottom of this.

Notes about following code segment

(1) strURL is same as what you navigate to when you use the file system

to browse your inbox, typically the M:/> drive on the exchange box

(2) the syntax for record.open is:

record.Open [source], [active connection], [mode], [createoptions],

[options (adOpenAsync)], [username (of mailbox)], [password (of the

account for mailbox)]

(3) Record.GetChildren returns recordset if record is a folder

(4) query string uses double and single quotes, so you my use of

duplicate double quotes is intentional



Recommended reading if you are doing this:

Programming Collaborative Web Applications with MS Exchange 2000 Server

by Mindy Martin .... Microsoft Programming Series MS Press



---

Bruce Pezzlo

MCSD & MCDBA

President

PLUM Computer Consulting, Inc.

(617) 266 - 1942 x201

Fax: (617) 267 - 0895

bpezzlo@p...







' BEGIN CODE EXAMPLE



' use ado to navigate exchange 2000 web storage system



Dim strURL as string

strURL =3D

"file://./backofficestorage/yourdomain.com/mbx/youremailname/Inbox"

Dim adoCon as ADODB.Connection

Set adoCon =3D New ADODB.Connection

adoCon.Provider =3D "exoledb.datasource"

adoCon.Open strURL



'get all mail

Dim adoRec as ADODB.Record

Set adoRec =3D New ADODB.Record

adoRec.Open strURL, adoCon, adModeRead, , adOpenAsync, username,

password

Dim adoRS as ADODB.Recordset

Set adoRS =3D adoRec.GetChildren



Do Until adoRS.EOF

	Debug.Print adoRS.Fields("DAV:displayname") & vbCrLf

	adoRS.MoveNext

Loop



'same thing, except this time, get only mail that meets criteria of

query string

Dim strSQL =3D "Select ""DAV:displayname"" FROM SCOPE('DEEP traversal of

""" & strURL & """') WHERE (""DAV:isfolder"" =3D True) ORDER BY

""DAV:displayname"" DESC"



Set adoRS =3D New ADODB.Recordset

adoRS.Open strSQL, adoCon



Do Until adoRS.EOF

	Debug.Print adoRS.Fields("DAV:displayname") & vbCrLf

	adoRS.MoveNext

Loop

adoRS.Close

Set adoRS =3D Nothing

Set adoCon =3D Nothing





' END CODE EXAMPLE





---

Bruce Pezzlo

MCSD & MCDBA

President

PLUM Computer Consulting, Inc.

(617) 266 - 1942 x201

Fax: (617) 267 - 0895

bpezzlo@p...









-----Original Message-----

From: Kish, Bill [mailto:Bill.Kish@D...]

Sent: Wednesday, November 14, 2001 8:49 AM

To: Bruce J. Pezzlo

Subject: exchange





Can you show me how to do this?





thanks, bill



Disclaimer

1. This e-mail is for the intended recipient only. If you have received

it

by mistake please let us know by reply and then delete it from your

system;

access, disclosure, copying, distribution or reliance on any of it by

anyone

else is prohibited.



2. If you as intended recipient have received this e-mail incorrectly,

please notify the sender (via e-mail) immediately. This e-mail is

confidential and may be legally privileged. DSM does not guarantee that

the

information sent and/or received by or with this e-mail is correct and

does

not accept any liability for damages related thereto.







-----Original Message-----

From: Bruce J. Pezzlo

Sent: Tuesday, November 13, 2001 12:19 PM

To: 'ASP components'

Subject: RE: [asp_components] Com object to read Mail?





I responded before with CDO (collaborative data objects) as a

suggestion.  You mention eml ... are you using exchange 2000?  If so,

the email is essentially stored by exchange in a database which you may

query as you'd like, without having to extract the stuff and put into

another db which is, as I understand it, your intention ( I can get you

examples of extracting this info with ADO if Exchange 2000 is what your

are using.) 



I'm not sure what your doing, so if CDO doesn't help you ( CDONTS ,

CDOSession ) look for SendMail.ExchangeEMail .  Or, explain where the

eml is coming from (is it simply plain  incoming email, or are the eml

files in some folder you are navigating to using Exchange 2000).



Bruce





---

Bruce Pezzlo

MCSD & MCDBA

President

PLUM Computer Consulting, Inc.

(617) 266 - 1942 x201

Fax: (617) 267 - 0895

bpezzlo@p...





-----Original Message-----

From: rich [mailto:shinecello@h...]

Sent: Tuesday, November 13, 2001 6:39 AM

To: ASP components

Subject: [asp_components] Com object to read Mail?





Hi



I am using SMTP service to retrieve e-mail. I am looking for a COM

component/ASP script that seperates the .eml file (e.g To, From,

Subject,

Attachments etc. so I can store the e-mail in a database.



I'm sure I found a page on this before, however I can't find it now!



Thanks



Richard






$subst('Email.Unsub')


  Return to Index