Click to See Complete Forum and Search --> : Error when sending Email with sendhtmlmail


Foundas
05-12-2005, 08:17 AM
Hi all,

i am facing the following problem. I am using sendhtmlmail function to send emails.

I use a different file as basic format (payment.htm) and i substitute its fields according to my user.

-------------------------------------------------------------------------

msgl=getfile("payment.htm")
msg1=replace(msgl,"#username#",rs2("username"))
msg1=replace(msg1,"#firstname#",rs2("firstname"))
msg1=replace(msg1,"#date#",rs3("date"))
msg1=replace(msg1,"#desc#",rs1("name") & " (" & rs1("credits") & " credits.)")
msg1=replace(msg1,"#amount#",rs1("amount"))
msg1=replace(msg1,"#credits#",rs1("credits"))
msg1=replace(msg1,"#validity#",rs1("validity"))
msg1=replace(msg1,"#payment#",rs3("transaction"))
msg1=replace(msg1,"#email#",rs2("email"))

sendhtmlmail " <info@domain.com >",rs2("email"),"Receipt for Payment",msg1
-----------------------------------------------------------------------

this is the sendhtmlmail function:
sub sendhtmlmail(from,too,subject,body)

Set MyMail = CreateObject("cdo.message")
MyMail.From = from
MyMail.To = too
MyMail.Subject = subject
MyMail.TextBody = body
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.domain.com"
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
MyMail.Configuration.Fields.Update
MyMail.Send



end sub

here is the problem. The email is sent successfully, the fields are updated correctly, but in the body of the email i see the HTML code of payment.htm. <body><head> etc etc.

please advice on how to fix this

thanks in advance,

Foundas

buntine
05-12-2005, 08:39 AM
You need to set the MailFormat and BodyFormat parameters.

MyMail.BodyFormat = 0
MyMail.MailFormat = 0

0 is the constant value for HTML.

Regards.

Foundas
05-12-2005, 08:47 AM
Hi buntime

i get the following error

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'MyMail.BodyFormat'

/mailcode.inc, line 27


this is the function:

MyMail.BodyFormat = 0
MyMail.MailFormat = 0
MyMail.From = from
MyMail.To = too
MyMail.Subject = subject
MyMail.TextBody = body
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.domain.com"
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
MyMail.Configuration.Fields.Update
MyMail.Send

Foundas
05-12-2005, 09:15 AM
found the solution

i changed

MyMail.TextBody = body to
MyMail.HtmlBody = Body

:)


cheers

buntine
05-12-2005, 09:42 AM
Your welcome ;)