Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

ASP Email Code / MIME Types?


  • Please log in to reply

#1
Immortalarena

Immortalarena

    Member

  • 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

[codebox]<!--
METADATA
TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Library"
-->
<%Response.Buffer=TRUE%>
<%
'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
Else
if rsMyDB("mailings") = "No" then
'Do Nothing Again
Else
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"
.Update
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
.Send
End With
End If
End If
'Move to the next record in the recordset
rsMyDB.MoveNext
Loop

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


Set cdoMessage = Nothing
Set cdoConfig = Nothing
if err = 0 then
Response.write("Messages Sent!")
end if
%>[/codebox]

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!

-Matt
  • 0

Advertisements







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