|
 |
asp_cdo thread: CDONTS newmail
Message #1 by Robert Link <robert@n...> on Mon, 30 Oct 2000 12:57:06 -0800
|
|
I'm sending mail via cdonts, and all works well, except I want to send
text-only mail, and I can't seem to get a line break in the body. All
clues welcome! I've tried vbcrlf, chr(13), chr(10) outside the double
quoted text for the body string, and \r within the double quoted
portion. Here's the relevant code (mostly hacked from the ms site), note
that I've set to send text only, instead of html (call me a luddite):
set rs10day = createobject("adodb.recordset")
rs10day.open sqlstr, globalConnStr, 1, 3
'--------------------------------------------------------------------
'
' Mailout using CDONTS.NewMail
'
'--------------------------------------------------------------------
' declare all variables
' Option Explicit
Dim objSendMail
Dim strTo, strFrom
Dim strSubject, strBody
' mail constants (some are for reference)
Const CdoBodyFormatHTML = 0 ' Body property is HTML
Const CdoBodyFormatText = 1 ' Body property is plain text (default)
Const CdoMailFormatMime = 0 ' NewMail object is in MIME format
Const CdoMailFormatText = 1 ' NewMail object is plain text (default)
Const CdoLow = 0 ' Low importance
Const CdoNormal = 1 ' Normal importance (default)
Const CdoHigh = 2 ' High importance
counter = 0
if not (rs10day.bof and rs10day.eof) then
while not rs10day.eof
strFrom = "prog@b... ' change to your email address
strTo = rs10day("Email") ' change to the recipient's address
strSubject = "SQL tester" ' change to your subject
counter = counter + 1
sb = "Dear " & rs10day("FirstName") & ","
sb = sb &"Your free trial to Foo.com expires soon! "
sb = sb & "Email foo@b... to sign up for"
sb = sb & " a permanent account."
sb = sb & date & " " & counter
sb = sb & formdate
strBody = sb
' the following section creates the mail object and sends the mail
Set objSendMail = CreateObject("CDONTS.NewMail")
objSendMail.From = strFrom
objSendMail.To = strTo
objSendMail.Subject = strSubject & " (" & Date() & ")"
objSendMail.Body = strBody
objSendMail.BodyFormat = CdoBodyFormatText
objSendMail.MailFormat = CdoMailFormatMime
objSendMail.Importance = CdoNormal
objSendMail.Send
Set objSendMail = Nothing
rs10day.movenext
wend
end if
rs10day.close
set rs10day = nothing
Message #2 by Tony@a... on Tue, 31 Oct 2000 11:06:21 +1100
|
|
To put a line between your text-only emails try using:
VBCRLF = vb carriage return line feed put two in to have a line separating
the paragraphs
eg
bodytext = "This is a paragraph." & VBCRLF & VBCRLF & "This is a new
paragraph."
Cheers From
Tony Xavier
Web Developer
The Axis Media Group
0419 236 109
-----Original Message-----
From: ASP CDO digest [mailto:asp_cdo@p...]
Sent: Tuesday, 31 October 2000 7:00 PM
To: asp_cdo digest recipients
Subject: asp_cdo digest: October 30, 2000
ASP_CDO Digest for Monday, October 30, 2000.
1. CDONTS newmail
----------------------------------------------------------------------
Subject: CDONTS newmail
From: Robert Link <robert@n...>
Date: Mon, 30 Oct 2000 12:57:06 -0800
X-Message-Number: 1
I'm sending mail via cdonts, and all works well, except I want to send
text-only mail, and I can't seem to get a line break in the body. All
clues welcome! I've tried vbcrlf, chr(13), chr(10) outside the double
quoted text for the body string, and \r within the double quoted
portion. Here's the relevant code (mostly hacked from the ms site), note
that I've set to send text only, instead of html (call me a luddite):
set rs10day = createobject("adodb.recordset")
rs10day.open sqlstr, globalConnStr, 1, 3
'--------------------------------------------------------------------
'
' Mailout using CDONTS.NewMail
'
'--------------------------------------------------------------------
' declare all variables
' Option Explicit
Dim objSendMail
Dim strTo, strFrom
Dim strSubject, strBody
' mail constants (some are for reference)
Const CdoBodyFormatHTML = 0 ' Body property is HTML
Const CdoBodyFormatText = 1 ' Body property is plain text (default)
Const CdoMailFormatMime = 0 ' NewMail object is in MIME format
Const CdoMailFormatText = 1 ' NewMail object is plain text (default)
Const CdoLow = 0 ' Low importance
Const CdoNormal = 1 ' Normal importance (default)
Const CdoHigh = 2 ' High importance
counter = 0
if not (rs10day.bof and rs10day.eof) then
while not rs10day.eof
strFrom = "prog@b... ' change to your email address
strTo = rs10day("Email") ' change to the recipient's address
strSubject = "SQL tester" ' change to your subject
counter = counter + 1
sb = "Dear " & rs10day("FirstName") & ","
sb = sb &"Your free trial to Foo.com expires soon! "
sb = sb & "Email foo@b... to sign up for"
sb = sb & " a permanent account."
sb = sb & date & " " & counter
sb = sb & formdate
strBody = sb
' the following section creates the mail object and sends the mail
Set objSendMail = CreateObject("CDONTS.NewMail")
objSendMail.From = strFrom
objSendMail.To = strTo
objSendMail.Subject = strSubject & " (" & Date() & ")"
objSendMail.Body = strBody
objSendMail.BodyFormat = CdoBodyFormatText
objSendMail.MailFormat = CdoMailFormatMime
objSendMail.Importance = CdoNormal
objSendMail.Send
Set objSendMail = Nothing
rs10day.movenext
wend
end if
rs10day.close
set rs10day = nothing
Message #3 by sachin singhal <shivsachin_2000@y...> on Tue, 31 Oct 2000 01:28:11 -0800 (PST)
|
|
Hi,
For this try html tag called <pre></pre>in the body
part it will keep all format same
sachin
--- Robert Link <robert@n...> wrote:
>
>
> I'm sending mail via cdonts, and all works well,
> except I want to send
> text-only mail, and I can't seem to get a line break
> in the body. All
> clues welcome! I've tried vbcrlf, chr(13), chr(10)
> outside the double
> quoted text for the body string, and \r within the
> double quoted
> portion. Here's the relevant code (mostly hacked
> from the ms site), note
> that I've set to send text only, instead of html
> (call me a luddite):
>
>
>
> set rs10day = createobject("adodb.recordset")
> rs10day.open sqlstr, globalConnStr, 1, 3
>
>
'--------------------------------------------------------------------
> '
> ' Mailout using CDONTS.NewMail
> '
>
'--------------------------------------------------------------------
>
> ' declare all variables
> ' Option Explicit
> Dim objSendMail
> Dim strTo, strFrom
> Dim strSubject, strBody
>
> ' mail constants (some are for reference)
> Const CdoBodyFormatHTML = 0 ' Body property is HTML
> Const CdoBodyFormatText = 1 ' Body property is plain
> text (default)
> Const CdoMailFormatMime = 0 ' NewMail object is in
> MIME format
> Const CdoMailFormatText = 1 ' NewMail object is
> plain text (default)
> Const CdoLow = 0 ' Low importance
> Const CdoNormal = 1 ' Normal importance
> (default)
> Const CdoHigh = 2 ' High importance
>
> counter = 0
>
> if not (rs10day.bof and rs10day.eof) then
> while not rs10day.eof
> strFrom = "prog@b... ' change to your email
> address
>
> strTo = rs10day("Email") ' change to the
> recipient's address
> strSubject = "SQL tester" ' change to your
> subject
>
> counter = counter + 1
> sb = "Dear " & rs10day("FirstName") & ","
> sb = sb &"Your free trial to Foo.com expires soon!
> "
> sb = sb & "Email foo@b... to sign up for"
> sb = sb & " a permanent account."
> sb = sb & date & " " & counter
> sb = sb & formdate
> strBody = sb
>
> ' the following section creates the mail object and
> sends the mail
> Set objSendMail = CreateObject("CDONTS.NewMail")
> objSendMail.From = strFrom
> objSendMail.To = strTo
> objSendMail.Subject = strSubject & " (" &
> Date() & ")"
> objSendMail.Body = strBody
>
> objSendMail.BodyFormat = CdoBodyFormatText
> objSendMail.MailFormat = CdoMailFormatMime
> objSendMail.Importance = CdoNormal
>
> objSendMail.Send
> Set objSendMail = Nothing
>
> rs10day.movenext
> wend
> end if
> rs10day.close
> set rs10day = nothing
>
>
Message #4 by Robert Link <robert@n...> on Tue, 31 Oct 2000 08:27:30 -0800
|
|
At 11:06 AM 10/31/2000 +1100, you wrote:
> >bodytext = "This is a paragraph." & VBCRLF & VBCRLF & "This is a new
> >paragraph."
vbcrlf wasn't doing me any good until I removed:
objSendMail.BodyFormat = 1
objSendMail.MailFormat = 0
objSendMail.Importance = 1
Now, I don't really think the "importance" flag affected things, so it's
either the bodyformat or the mailformat. I explicitly need to send text
only, not html mail, hence the bodyformat of one. But I don't know which
made the difference, letting bodyformat go at defaults or mailformat.
--
Robert Link
|
|
 |