Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDONTS 1

Status
Not open for further replies.

krieghof

Programmer
Apr 14, 2003
13
GB
Strange one this...

I'm using cdonts

Function sendMail(fromName, from, rcpt, subject, body)

Set mail = Server.CreateObject ("CDONTS.NewMail")

mail.BodyFormat = 1
mail.MailFormat = 0

on error resume next

mail.Send from, rcpt, subject, body

end if

if err <> 0 then
'unrem if you want to debug email errors
'response.Write &quot;<br><br> Error sending email: &quot; & Err.Description & &quot;. Have you installed an email component in this system?&quot;
'response.Write &quot;<hr><br>From &quot;&from
'response.Write &quot;<br>To &quot;&rcpt
'response.Write &quot;<br>Subject &quot;&subject
'response.Write &quot;<br>Body &quot;&body
end if

end Function

i get no error, no problem with to and from but it does not send a message, i have smtp install because my site uses it.. is there something i may be missing?
 
Does CDONTS need a delay when call the object until the next call?
 
Why do you have an end if in the middle of your function code?

Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
Well spotted but that was'nt the problem.. my settings page was not locatable...

I do however have another query, how does one create a html formatted mail? I have mailFormat = 0 MIME
 
You need to set both MailFormat and BodyFormat to 0.

--James
 
Hi James

Is it possible then to just drop html code into a <textarea> field in a form and send it? i believe i need to parse the text somewhat#?
 
Shouldn't need to do anything with it. I wrote this little test script to see what would happen - try it yourself:

Code:
<%
Option Explicit

Dim strTo, strMsg
Dim objMail

strTo = Request.Form(&quot;txtTo&quot;)
strMsg = Request.Form(&quot;txtMsg&quot;)

If strTo <> &quot;&quot; Then
  Set objMail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)

  With objMail
    .From = &quot;me@mydomain.com&quot;
    .To = strTo
    .Body = strMsg
    .MailFormat = 0
    .BodyFormat = 0
    .Send
  End With

  Set objMail = Nothing
End If
%>

<html>
<head>
<title>Test HTML mail</title>
</head>

<body>
<form action=&quot;test.asp&quot; method=&quot;post&quot;>
To: <input type=&quot;text&quot; name=&quot;txtTo&quot; /><br />
Message:<br />
<textarea name=&quot;txtMsg&quot; rows=&quot;10&quot; cols=&quot;50&quot;></textarea><br />
<input type=&quot;submit&quot; value=&quot;Send&quot; />
</form>

</body>
</html>

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top