Oct 19, 2007

Using CDO Email Encoding

public sub SendEmail(_
astrRecipientEmailAddress, _
astrCCEmailAddress, _
astrBCCEmailAddress, _
astrSenderEmailAddress, _
astrEmailSubject, _
astrEmailText)

'Dimension local variables
Dim objCDOMail


'Create Server Object
Set objCDOMail = Server.CreateObject("CDO.Message")

objCDOMail.From = astrSenderEmailAddress
objCDOMail.To = astrRecipientEmailAddress
objCDOMail.Subject = astrEmailSubject
objCDOMail.TextBody = astrEmailText

'this is the encoding part if you are using text as mail content
objCDOMail.BodyPart.Charset = "utf-8"
objCDOMail.TextBodyPart.Charset = "utf-8"

'this is the encoding part if you are using html as mail content
'create a proper html tag
'with Content-Type: text/html; charset=utf-8
objCDOMail.BodyPart.Charset = "utf-8"
objCDOMail.HtmlBodyPart.Charset = "utf-8"


'check whether to Copy or BCC this email
if len(astrCCEmailAddress) > 0 then
objCDOMail.CC = astrCCEmailAddress
end if
if len(astrBCCEmailAddress) > 0 then
objCDOMail.BCC = astrBCCEmailAddress
end if

objCDOMail.Send


end sub

No comments:

Post a Comment