ck_damu
asked on
vbCrLf giving problems in ASP
Hi,
This is the function i am using for sending mails.
I want to send this contents in mail in asp.
Address is
subject = "Camp Scholarship Application"
sbody = " Camp Education Program testing and the funding to be manipulated " & vbCrlf & _
" Te Undergraduate Application " & vbCrlf
sendmail "test@xyz.com","test@xyz.c om","admin @xyz.com", subject,sb ody,"T"
the email code i used is
function SendMail(aToAddress, aCC, aFromAddress, aSubj, aText, aFormat)
dim Mail
set Mail = Server.CreateObject("CDONT S.NewMail" )
'fill email fields
Mail.From = aFromAddress 'To and From addresses must be in
Mail.To = aToAddress 'valid "user@domain.com" format
Mail.CC = aCC
Mail.Subject = aSubj
Mail.Body = aText
if aFormat = "H" then
Mail.BodyFormat = 0 '0=HTML, 1=Text
Mail.MailFormat = 0 '0=MIME, 1=Text
else
Mail.BodyFormat = 1 '0=HTML, 1=Text
Mail.MailFormat = 1 '0=MIME, 1=Text
end if
Mail.Send 'email this message
set Mail = Nothing 'free the message object
SendMail = true
end function
email gets sent but the the formatting changes.
the email i get is simply a text messsage without any formatting. Something like this.
" Camp Education Program testing and the funding to be manipulated Te Undergraduate Application "
hwo can we make this working?
RD.
This is the function i am using for sending mails.
I want to send this contents in mail in asp.
Address is
subject = "Camp Scholarship Application"
sbody = " Camp Education Program testing and the funding to be manipulated " & vbCrlf & _
" Te Undergraduate Application " & vbCrlf
sendmail "test@xyz.com","test@xyz.c
the email code i used is
function SendMail(aToAddress, aCC, aFromAddress, aSubj, aText, aFormat)
dim Mail
set Mail = Server.CreateObject("CDONT
'fill email fields
Mail.From = aFromAddress 'To and From addresses must be in
Mail.To = aToAddress 'valid "user@domain.com" format
Mail.CC = aCC
Mail.Subject = aSubj
Mail.Body = aText
if aFormat = "H" then
Mail.BodyFormat = 0 '0=HTML, 1=Text
Mail.MailFormat = 0 '0=MIME, 1=Text
else
Mail.BodyFormat = 1 '0=HTML, 1=Text
Mail.MailFormat = 1 '0=MIME, 1=Text
end if
Mail.Send 'email this message
set Mail = Nothing 'free the message object
SendMail = true
end function
email gets sent but the the formatting changes.
the email i get is simply a text messsage without any formatting. Something like this.
" Camp Education Program testing and the funding to be manipulated Te Undergraduate Application "
hwo can we make this working?
RD.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Preece is correct, you are trying to put in textual carriage breaks, when you are sending an html email
once you change them to the <br>'s you should be all set
once you change them to the <br>'s you should be all set
ASKER
HTML format works but Text format is giving problems, formatting is not working.
if you reduce the contents in sbody
i.e
sbody = " Camp Education Program"
sbody = sbody & vbCrLf & " The Undergraduate Application " & vbCrLf
This works, donno why?
RD
if you reduce the contents in sbody
i.e
sbody = " Camp Education Program"
sbody = sbody & vbCrLf & " The Undergraduate Application " & vbCrLf
This works, donno why?
RD
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So, you are building your sbody and making the correctly in both scenarios? Such as:
sbody = " Camp Education Program"
sbody = sbody & vbCrLf & " The Undergraduate Application " & vbCrLf
sendmail "test@xyz.com","test@xyz.c om","admin @xyz.com", subject,sb ody,"T"
sbody = " Camp Education Program"
sbody = sbody & "<br>" & " The Undergraduate Application " & "<br>"
sendmail "test@xyz.com","test@xyz.c om","admin @xyz.com", subject,sb ody,"H"
I wonder if it has anything to do with the Mail.MailFormat setting?
Preece
sbody = " Camp Education Program"
sbody = sbody & vbCrLf & " The Undergraduate Application " & vbCrLf
sendmail "test@xyz.com","test@xyz.c
sbody = " Camp Education Program"
sbody = sbody & "<br>" & " The Undergraduate Application " & "<br>"
sendmail "test@xyz.com","test@xyz.c
I wonder if it has anything to do with the Mail.MailFormat setting?
Preece
ASKER
Try the below two code segment you can find the difference
1)
sbody = " Camp Education Program"
sbody = sbody & vbCrLf & " The Undergraduate Application " & vbCrLf
sendmail "test@xyz.com","test@xyz.c om","admin @xyz.com", subject,sb ody,"T"
2)
sbody = " Camp Education Program testing and the funding to be manipulated "
sbody = sbody & vbCrLf & " Te Undergraduate Application " & vbCrlf
sendmail "test@xyz.com","test@xyz.c om","admin @xyz.com", subject,sb ody,"T"
RD
1)
sbody = " Camp Education Program"
sbody = sbody & vbCrLf & " The Undergraduate Application " & vbCrLf
sendmail "test@xyz.com","test@xyz.c
2)
sbody = " Camp Education Program testing and the funding to be manipulated "
sbody = sbody & vbCrLf & " Te Undergraduate Application " & vbCrlf
sendmail "test@xyz.com","test@xyz.c
RD
kevp75 is correct. Be sure to be consistent with your sbody formatting and your sendmail calling parameters.
Another option might to use CDO instead of CDONTS, if your server supports it:
subject = "Camp Scholarship Application"
if strFormat = "T" then
sbody = " Camp Education Program"
sbody = sbody & vbCrLf & " The Undergraduate Application " & vbCrLf
sendmail "test@xyz.com","test@xyz.c om","admin @xyz.com", subject,sb ody,"T"
else if strFormat = "H" then
sbody = " Camp Education Program"
sbody = sbody & "<br>" & " The Undergraduate Application " & "<br>"
sendmail "test@xyz.com","test@xyz.c om","admin @xyz.com", subject,sb ody,"H"
end if
function gsnSendMail(aToAddress, aCC, aFromAddress, aSubj, aText, aFormat))
Dim myMail
Set myMail = Server.CreateObject("CDO.M essage")
myMail.From = aFromAddress
myMail.To = aToAddress
myMail.CC = aCC
'myMail.BCC = aBCC
myMail.Subject = aSubj
if aFormat = "H" then
myMail.HtmlBody = aText
else if aFormat = "T" then
myMail.TextBody = aText
end if
myMail.Send
Set myMail = Nothing
end function
Preece
Another option might to use CDO instead of CDONTS, if your server supports it:
subject = "Camp Scholarship Application"
if strFormat = "T" then
sbody = " Camp Education Program"
sbody = sbody & vbCrLf & " The Undergraduate Application " & vbCrLf
sendmail "test@xyz.com","test@xyz.c
else if strFormat = "H" then
sbody = " Camp Education Program"
sbody = sbody & "<br>" & " The Undergraduate Application " & "<br>"
sendmail "test@xyz.com","test@xyz.c
end if
function gsnSendMail(aToAddress, aCC, aFromAddress, aSubj, aText, aFormat))
Dim myMail
Set myMail = Server.CreateObject("CDO.M
myMail.From = aFromAddress
myMail.To = aToAddress
myMail.CC = aCC
'myMail.BCC = aBCC
myMail.Subject = aSubj
if aFormat = "H" then
myMail.HtmlBody = aText
else if aFormat = "T" then
myMail.TextBody = aText
end if
myMail.Send
Set myMail = Nothing
end function
Preece
Also, don't forget the h in"
" Te Undergraduate Application "
Preece
" Te Undergraduate Application "
Preece
oops, a couple of typos:
Another option might to use CDO instead of CDONTS, if your server supports it:
subject = "Camp Scholarship Application"
if strFormat = "T" then
sbody = " Camp Education Program"
sbody = sbody & vbCrLf & " The Undergraduate Application " & vbCrLf
gsnSendMail "test@xyz.com","test@xyz.c om","admin @xyz.com", subject,sb ody,"T"
else if strFormat = "H" then
sbody = " Camp Education Program"
sbody = sbody & "<br>" & " The Undergraduate Application " & "<br>"
gsnSendMail "test@xyz.com","test@xyz.c om","admin @xyz.com", subject,sb ody,"H"
end if
function gsnSendMail(aToAddress, aCC, aFromAddress, aSubj, aText, aFormat)
Dim myMail
Set myMail = Server.CreateObject("CDO.M essage")
myMail.From = aFromAddress
myMail.To = aToAddress
myMail.CC = aCC
'myMail.BCC = aBCC
myMail.Subject = aSubj
if aFormat = "H" then
myMail.HtmlBody = aText
else if aFormat = "T" then
myMail.TextBody = aText
end if
myMail.Send
Set myMail = Nothing
end function
Preece
Another option might to use CDO instead of CDONTS, if your server supports it:
subject = "Camp Scholarship Application"
if strFormat = "T" then
sbody = " Camp Education Program"
sbody = sbody & vbCrLf & " The Undergraduate Application " & vbCrLf
gsnSendMail "test@xyz.com","test@xyz.c
else if strFormat = "H" then
sbody = " Camp Education Program"
sbody = sbody & "<br>" & " The Undergraduate Application " & "<br>"
gsnSendMail "test@xyz.com","test@xyz.c
end if
function gsnSendMail(aToAddress, aCC, aFromAddress, aSubj, aText, aFormat)
Dim myMail
Set myMail = Server.CreateObject("CDO.M
myMail.From = aFromAddress
myMail.To = aToAddress
myMail.CC = aCC
'myMail.BCC = aBCC
myMail.Subject = aSubj
if aFormat = "H" then
myMail.HtmlBody = aText
else if aFormat = "T" then
myMail.TextBody = aText
end if
myMail.Send
Set myMail = Nothing
end function
Preece
i'd like to know the outcome....
sendmail "test@xyz.com","test@xyz.c
be passing an H instead of a T?
sendmail "test@xyz.com","test@xyz.c
Preece