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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Body property of CDONTS.NewMail 1

Status
Not open for further replies.

larryman

Programmer
Jun 16, 2000
63
US
Hi,

Is there a limit to the number of characters the Body property of CDONTS.NewMail can take.

I have a problem with the script below


<% @Language=&quot;VBScript&quot;%>
<%
Option Explicit
'declare all local variables

dim dcnDB 'As ADO.Connection
dim strSQL 'As String
Dim Mymail 'As CDONTS component
Dim rs 'As recordset 2
dim Message_Title
Dim Message_Body
Dim Email
Dim Kount

'Create the Connection Object
%>

<%
Set dcnDB = Server.CreateObject(&quot;ADODB.Connection&quot;)
dcnDB.ConnectionString = &quot;Provider=Microsoft.Jet.OLEDB.4.0;&quot;_
& &quot;Data Source=f:\Aspdatabase\Database\success.mdb&quot;
dcnDB.Open



'Create the recordset object


Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
strSQL = &quot;SELECT * FROM Mailing_ListTemp&quot;
Set rs = dcnDB.Execute(StrSQL)



Message_Title = Request.Form(&quot;Category_Title&quot;)
Message_Body = Request.Form(&quot;Category_Message&quot;)

Kount = 0


Do While NOT rs.EOF

Set myMail = CreateObject(&quot;CDONTS.NewMail&quot;)
myMail.From = &quot;mymail@mydomain.com&quot;
myMail.To = rs(&quot;email1&quot;)
myMail.Subject = Message_Title
myMail.BodyFormat = 1
myMail.MailFormat = 1
myMail.Body = Message_Body
myMail.Send
Kount = Kount + 1


rs.MoveNext
Loop
%>

The message in my Message_Body is being truncated say after the first fifty words. I wouldn't know whether i'm missing something out


Oysterbar ride to success. Keep Riding
 
There might be a limit but it is certainly more than 50 characters as I have sent mails that are several pages long. I'm only guessing here but check to see if there are any quotes or other characters in your body that might make the system think it's the end of the message. Mighty :)
 
Mighty,
Thanks i have quotes in the message body and the sent message stopped exactly right before the first quote. How do i handle this and other characters that might make the system think it's the end of the message.

Thanx Oysterbar ride to success. Keep Riding
 
Just replace the quotes. Try the following:

myMail.Body = Replace(Message_Body, &quot;&quot;&quot;&quot;, &quot;&quot;&quot;&quot;&quot;&quot;) Mighty :)
 
Mighty
I have implemented the replace but it's the same thing. When i manually deleted the quotes, it worked to the point of next quote. What could be wrong? Please what are other characters that could cause this kind of action.

Thanks Oysterbar ride to success. Keep Riding
 
CAn you post the body the mail here so that I can have a look at it. Mighty :)
 
Alright,

Here goes the message:

Author and preacher E.W. Kenyon once said, &quot;The things that makes opportunity, that makes money, that saves money, that creates new things, that brings together things that others have created but are unable to utilizes is inside you. Find it and make it work&quot;.

Yes dear reader that potential for success is inside you. Find it. Release it. It will take you to the top. This week we are discussing SELF - RELIANCE.

The greater part of the wealth of this world is not in the oil deposits of Nigeria, Indonesia or Saudi Arabia. It's not in the gold or diamond mines of South Africa. Instead, God has put the greatest resources inside us. These treasures are so close to us that we usually do not recognize them.

Today, you will locate your inner resources. You will develop them and give them commercial value and your life will begin to attract wealth. You may have waited for so long for others to help you but the greatest helping hand you will find is the one attached to your shoulder. You see, what you do for yourself counts far more than what others have done or will ever do for you. Others may have failed in their responsibility towards you but you must not fail in your responsibility to yourself. Don't sit down and blame everybody else for your woes while refusing to do something about your situation because you are not yet a failure until you blame someone else.

You owe it to God and to yourself to rise up to the occasion. God will help you to
breakthrough.

God bless you.

====================================================================================

To subscribe send a mail to our mailing list.
Oysterbar ride to success. Keep Riding
 
The replace should have fixed that. Try the following:

myMail.Body = Replace(Message_Body, &quot;&quot;&quot;&quot;, &#34;) Mighty :)
 
That didn't come out properly. You need to add in the escape sequence for the quotes which is:

& # 3 4 ;

Remove the spaces between the characters above.

myMail.Body = Replace(Message_Body, &quot;&quot;&quot;&quot;, &quot;)

In place of the final quote above, use the escape sequence without the spaces. Mighty :)
 
Sorry,

If i understand replace function i think it's to replace every occurence of a substring in another string with a replacement string.

If any quote is encountered in the message body of the script, it's to be converted.

Now my problem is what should the quote be converted to.

I have tried different versions with the escape sequence.
i even tried this Replace(Message_Body,&quot;&quot;&quot;&quot;,&quot;\&quot;&quot;&quot;) but it didn't work.
If you tried any one and it worked at your end let me know.

Thanks Oysterbar ride to success. Keep Riding
 
larryman,
I'm slightly confused here. I have been trying different things out and cannot get it to recreate the problem you are experiencing! I wrote this little test page:

Code:
<html>
<head>
<title>Testing</title>
</head>

<body>
<%
Message_Title = Request.Form(&quot;title&quot;)
Message_Body = Request.Form(&quot;msg&quot;)

If Message_Body <> &quot;&quot; Then

Set myMail = CreateObject(&quot;CDONTS.NewMail&quot;) 
myMail.From = &quot;me@mydomain.com&quot; 
myMail.To = &quot;me@mydomain.com&quot;
myMail.Subject = Message_Title 
myMail.BodyFormat = 1 
myMail.MailFormat = 1 
myMail.Body = Message_Body 
myMail.Send
Set myMail = Nothing

End If
%>

<form action=&quot;test.asp&quot; method=&quot;post&quot;>
<input type=&quot;text&quot; name=&quot;title&quot;><br>
<textarea name=&quot;msg&quot; rows=&quot;20&quot; cols=&quot;40&quot;></textarea><br>
<input type=&quot;submit&quot;>
</form>

</body>
</html>

I tried to use the exact same code as you for sending the mail (except getting the emails from the db). I found I could write anything in the subject or body fields (I even copy/pasted your mail text) and it would be reproduced exactly in the received email. No need to replace quotes or anything!

I even tried changing the email format to HTML (bodyformat = 0, mailformat = 0) but still worked fine.

Can you try this script and see what you get? --James
 
JamesLean

Sorry,
Could this be due to ASP version i run Version 3.0 Oysterbar ride to success. Keep Riding
 
JamesLean
The script worked.

I guess there is a proble somewhere that i still have to figure out.

Thanx

Larryman Oysterbar ride to success. Keep Riding
 
What's the code for your form? Are you doing any validation or processing the input at all before posting the data to the send mail page? --James
 
Okay, there are two pages in the Send mail process.
The first page will pick information from the Messages Table in a database. The table has two fields (1)Message_Title which holds the title of the of the message (2) Message which holds the message itself.
I grabbed this information and put in a hidden box on the next page. The next page asks for the Mailing list category and this will be used in the SQL stm.

When i viewed the HTML of the second page i was able to see the hidden field with the whole text but when i send it out using CDONTS, the problem starts. Oysterbar ride to success. Keep Riding
 
From what you say, I would guess the problem lies when you put the data from the DB into the form. You probable have something like this?:

Code:
<%
'open conn and get recordset
%>

<form>
<input type=&quot;hidden&quot; value=&quot;<%= rs(&quot;message&quot;) %>&quot;>
</form>

Try using replace on THIS page:

Code:
<input type=&quot;hidden&quot; value=&quot;<%= Replace(rs(&quot;message&quot;), &quot;&quot;&quot;&quot;, &quot;&quot;&quot;&quot;&quot;&quot;) %>&quot;>

Actually, I would be tempted not to send the whole message through two pages (it looks like it can get quite long?) Instead, just pass the ID of the record and look up the actual message text on the page where you send the mail. --James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top