Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

ASP Email Code / MIME Types?

  • Please log in to reply




  • Member
  • PipPipPip
  • 216 posts
I am working on a site where we want to send out a newsletter. The problem is that I cannot get the information I want sent right. I would like to send it as an HTML code, but have a text body sent to allow those in webmail, or settings where HTML and Images are blocked can still read the information.

Here is the Code

NAME="CDO for Windows 2000 Library"
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsMyDB 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
Dim mailingemail
dim msgstring

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("_private/mydb.mdb")

'Create an ADO recordset object
Set rsMyDB = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT users.* FROM users"

'Open the recordset with the SQL query
rsMyDB.Open strSQL, adoCon

'Loop through the recordset
Do While not rsMyDB.EOF
'Start My Code
if rsMyDB("auth") = "inactive" Then
'Do Nothing
if rsMyDB("mailings") = "No" then
'Do Nothing Again
Set cdoConfig = CreateObject("CDO.Configuration")
Dim News_ID
News_ID = Request.Form("newsID")
With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "my smtp server"
.Item(cdoSMTPAuthenticate) = 1
.Item(cdoSendUsername) = "my username"
.Item(cdoSendPassword) = "my password"
End With

MHTMLBody = "http://troop101.net/...er.asp?newsID=" & News_ID
msgstring = "HTML View has been disabled on your machine, please go to: " & _
"http://troop101.net/...er.asp?newsID=" & News_ID & " To view it."

Set cdoMessage = CreateObject("CDO.Message")

With cdoMessage
Set .Configuration = cdoConfig
.CreateMHTMLBody MHTMLBody
.From = "From Email"
.To = rsMyDB("email")
.Subject = "Troop 101 Newsletter"
.TextBody = msgstring
End With
End If
End If
'Move to the next record in the recordset

'Reset server objects
Set rsMyDB = Nothing
Set adoCon = Nothing

Set cdoMessage = Nothing
Set cdoConfig = Nothing
if err = 0 then
Response.write("Messages Sent!")
end if

So I would like to send mime types I think... That is what someone told me the other day when I was talking with them. The code above is the best I have right now, and hopefully I will be able to get it running soon. I would like to send out HTML code and plain text so that when read in a browsers webmail the message will still get through. Thanks!

  • 0


Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP