OutFront Forums
     Home    Register     Search      Help      Login    

Sponsors
Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax
Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.
Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Follow Us
On Facebook
On Twitter
RSS
Via Email

Recent Posts
Todays Posts
Most Active posts
Posts since last visit
My Recent Posts
Mark posts read

 

CDOSYS with Importance Flag (and multi emails)

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP, PHP, and Database >> CDOSYS with Importance Flag (and multi emails)
Page: [1]
 
 
cliffdeen

 

Posts: 155
Joined: 4/12/2004
From: Mckinney, TX
Status: offline

 
CDOSYS with Importance Flag (and multi emails) - 2/25/2005 23:12:20   
Everyone - to help others in using Cdosys for emailing I thought it would be handy to post some code. It seems that documentation for certain aspects of Cdosys is spotty at best. Searching this forum I found a reference to setting the Importance flag for a email sent. However, one piece of code was not included in the thread so I am including it here. As a added bonus, I am also including a code example which allows you to send multiple emails based on a query from a db from a asp page. I hope this will save others the amount of time it took for me to track this down. While on the subject, kudos need to go to R. Douglass on this forum for helping me get the multiple email portion working.
Quick explanation:
Items in bold are items you will need to set for your dbserver/mail server.
Dim Field "email" is the email address column in the db query and is used as the variable for the .To.
The importance flag is set using the two lines prior to the .To. Note you need to use the Fields.Update function to get the importance flag to actually work. Importance # is 0 = Low 1= Normal and 2 = High.
DO While not RS.EOF will cause the email send to loop until the query rows are exhausted.
Finally - Cdosys on a asp page when executing does not display anything on the page. What I have done to give me a indication of a successful run is OUTSIDE the Code area - I place a <%=email%>. This will display the LAST send of the query when it has completed its' run. Note that code as shown is the only code on the page - no /html no /body - just the code.:)


Code:
<%
Dim cn, RS, SQL, Conn, email, Z

Dim objConfig ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields ' As ADODB.Fields

Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort = 2
Const cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic = 1
Const cdoSendUserName = "http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword = "http://schemas.microsoft.com/cdo/configuration/sendpassword"
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open("Provider=SQLOLEDB;Server=CRPDALMSQ06;Database=ukdashSQL1;UID=IMU;pwd=hmfic2004;")
'This next line is your SQL for the data you want to use
SQL = "Select * FROM emailtest"

set Conn=server.createobject("adodb.connection")
Conn.open cn
Set RS = Conn.Execute (SQL)

DO WHILE not RS.EOF
email=(rs("email"))
' Get a handle on the config object and it's fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields

' Set config fields we care about
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "smtp3dns.my email server.com"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Update
End With

Set objMessage = Server.CreateObject("CDO.Message")

Set objMessage.Configuration = objConfig
With objMessage
.Fields("urn:schemas:httpmail:importance").Value = 2
.Fields.Update()
.To = email
.From = "emailtest@myemailserver.com"
.Subject = "LET ME KNOW IF YOU GET THIS!"
.textbody = "Testing importance flag. Hey this works:"
.Send
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing

RS.MoveNext
Loop
Set RS = nothing
Conn.close
%>


Page:   [1]

All Forums >> Web Development >> ASP, PHP, and Database >> CDOSYS with Importance Flag (and multi emails)
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts