[thelist] Stumped by CDO
Sam Carter
sam at nativeintelligence.com
Fri Sep 5 13:13:25 CDT 2003
I have the following CDO function to send UNICODE email
Function SendEmail (strFrom, strTo, strCc, strBcc, strSubject, strBody)
Const cdoSendUsingPort = 2
Const cdoSendUsingMethod =
"http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSMTPServer =
"http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort =
"http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Dim objMail
on error resume next
strErrorMsg = ""
' Create the CDO Configuration Object and initialize
Set objConfiguration = CreateObject("CDO.Configuration")
Set objFields = objConfiguration.Fields
With objFields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPServer) = "localhost"
.Update
End With
' Create the CDO Message
Set objMessage = CreateObject("CDO.Message")
With objMessage
Set .Configuration = objConfiguration ' Configure the message communications
.MimeFormatted = TRUE
.From = strFrom
.To = strTo
.Cc = strCc
.Bcc = strBcc
.Subject = strSubject
With .Bodypart ' Initialize the bodypart to support UTF-8
.ContentMediaType = "text/plain"
.ContentTransferEncoding = "7bit"
.Charset = "utf-8"
SET Stm = .GetDecodedContentStream
Stm.WriteText strBody
Stm.Flush
End With
.Send
End With
SET objMessage = Nothing
SET objFields = Nothing
SET objConfiguration = Nothing
SendEmail = err.description ' Return last error if any
End Function
If strBody contains multiple lines, then Stm.WriteText strBody writes only
up to the first carriage return CHAR(13).
The body string is returned from a SQL stored procedure if that helps.
Is there any way to get the entire contents of strBody into the target email
body?
Thanks,
Sam
More information about the thelist
mailing list