Is there a limit to the body text in email? Strange...

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Is there a limit to the body text in email? Strange...

Post by Phil Pendlebury » Thu Mar 19, 2009 11:25 pm

Hi there.

This works for me fine:

Code: Select all

SMTPSendMail>[email protected],mail.xxxx.biz,[email protected],MEAP GNF,MEAP GNF Error,GNF Error,%SCRIPT_DIR%\screen\meapinfo.zip
meapinfo.zip is and attachment.

However,

This works but the attachment does not get attached:

Code: Select all

Let>app_date=March 19, 2009
Let>versionnum=6.62.105
Let>versionv=%versionnum% born on %app_date%

SMTPSendMail>[email protected],mail.xxxx.biz,[email protected],MEAP GNF,MEAP GNF Error,GNF Error%CRLF%%CRLF%OS = %OS_VER%.%CRLF%%CRFL%Version = %versionv%,%SCRIPT_DIR%\screen\meapinfo.zip
Any ideas?

:-)
Phil Pendlebury - Linktree

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Mar 20, 2009 1:17 am

Haven't tested any of this yet, but try removing the comma from the date.

If that works, then try this:

Code: Select all

Let>vComma=,
Let>app_date=March 19%vComma% 2009
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Fri Mar 20, 2009 1:19 am

Hi Phil,

Here's a few ideas:

In the code you posted, you have a %CRFL% but I think you wanted a %CRLF% there... Fix that and try again.

If still a problem, you might try to predefine more of the parameters into their own variables, try this:

Code: Select all

Let>app_date=March 19, 2009
Let>versionnum=6.62.105
Let>versionv=%versionnum% born on %app_date%
Let>body=GNF Error%CRLF%%CRLF%OS = %OS_VER%.%CRLF%%CRLF%Version = %versionv%
Let>attachment=%SCRIPT_DIR%\screen\meapinfo.zip

SMTPSendMail>[email protected],mail.xxxx.biz,[email protected],MEAP GNF,MEAP GNF Error,body,attachment
If that still doesn't send the attachment, then use the debugger and single step through... checking that each variable is being defined correctly.

Post back and let us know what you find. I know that having carriage returns and linefeeds within your body variable should be no problem and shouldn't "cut off" the attachment as I have scripts that do that.

Oops, I think I see the problem, your variable app_date contains a comma so your variable versionv will contain a comma... and the command is seeing that as a delimiting comma and therefore it isn't picking up your path to your attachment properly.

To see if that's the problem, replace that comma with another character and test. If it then works, that's it.

Side Question: Marcus - Could the SMTPSendMail> command be enhanced so that if an attachement is specified but it can't find that file (for whatever reason: file doesn't exist, drive inaccesible, whatever) then the command would error out saying what is wrong?

Update: I see Bob spotted the comma as well and posted while I was composing my reply...
Last edited by jpuziano on Fri Mar 20, 2009 2:10 am, edited 1 time in total.
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Fri Mar 20, 2009 2:07 am

Bob Hansen wrote:Paste the good line on top of the bad line with Word Wrap off, and the missing comma is obvious.
I did exactly what you said Bob, here are both Phil's original posted line and your modified line:

Code: Select all

SMTPSendMail>[email protected],mail.xxxx.biz,[email protected],MEAP GNF,MEAP GNF Error,GNF Error%CRLF%%CRLF%OS = %OS_VER%.%CRLF%%CRFL%Version = %versionv%,%SCRIPT_DIR%\screen\meapinfo.zip
SMTPSendMail>[email protected],mail.xxxx.biz,[email protected],MEAP GNF,MEAP GNF Error,GNF Error,%CRLF%%CRLF%OS = %OS_VER%.%CRLF%%CRLF%Version = %versionv%,%SCRIPT_DIR%\screen\meapinfo.zip
Looking at both of those in the editor with WordWrap off... you can pop the cursor back and forth between the two lines.

So place your cursor near the end of one one the lines, just prior to the last comma in the line that marks the boundary between the body and attachment parameters. In Phil's line, the first one, use the cursor keys to go before and after the comma and watch the indicator at the bottom of the editor window tell you... the parameter before the comma is the body... then move the cursor past the comma and it says attachment, that looks right.

Now do the same with your line and you'll see it shows you're already in the attachment parameter even before that last comma... so I don't think there should be a comma there.

I think Phil meant his "body" to be all of the following:

GNF Error%CRLF%%CRLF%OS = %OS_VER%.%CRLF%%CRFL%Version = %versionv%

Putting a comma after GNF Error... cuts the rest out of his body and spills it over into the attachment parameter.

Phil, you might also try isolating the comma as Bob had earlier mentioned:

Code: Select all

Let>vComma=,
Let>app_date=March 19
Let>versionnum=6.62.105
Let>versionv=%versionnum% born on %app_date%
Let>body=GNF Error%CRLF%%CRLF%OS = %OS_VER%.%CRLF%%CRLF%Version = %versionv%
Let>attachment=%SCRIPT_DIR%\screen\meapinfo.zip

SMTPSendMail>[email protected],mail.xxxx.biz,[email protected],MEAP GNF,MEAP GNF Error,body%vComma% 2009,attachment
Bob Hansen wrote:Good catch jpuziano on the wrong %CRFL%.
Thanks but I must admit the color syntax highlighting in the editor helped there... others were in red because CRLF is a system variable while CRFL isn't. I'm just glad Marcus implemented that enhancement suggestion (to show system variables in red)... because I am sure it will be helpful to all in spotting little typos like that.

On the subject of spotting errors in general and alerting the user... Marcus, can we get the item below added to the wish list?

Side Question: Marcus - Could the SMTPSendMail> command be enhanced so that if an attachment is specified but it can't find that file (for whatever reason: file doesn't exist, drive inaccessible, whatever) then the command would error out saying what is wrong?
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Mar 20, 2009 3:38 am

Boy, you are fast jpuziano. I realized my posting was incorrect and thought I deleted it immediately. But you got to it before me. Sorry you did all that work, I tried to stop it from happening. My error, sorry.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Fri Mar 20, 2009 7:31 am

I retyped the code (last thing at night) for this forum and typed it slightly wrong. Apologies for that. I assure you all parameters were correct in my script.

The code contained no actual commas or incorrectly spelled CRLF commands.

Did anyone actually try to reproduce this rather than just examining my badly typed code?

:-)


Having said that. There is a comma in the date that would have been there in the actual code.

I will fiddle with this if you guys are sure there is no issue with body length.

Thank you kindly.

:-)
Phil Pendlebury - Linktree

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Fri Mar 20, 2009 8:14 am

Right. Tested again.

It was indeed the comma.

Inserting a virtual comma makes no difference. It is still read as a comma.

Anyway, solved by simply removing the comma.

Thanks chaps.

:-)
Phil Pendlebury - Linktree

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Mar 20, 2009 9:26 am

If you need the comma, use separate variables:

Code: Select all

Let>body=some text, with a comma in it
Let>attach=C:\Documents\somefile.txt
SMTPSendMail>[email protected],server.com,[email protected],me,some subject,body,attach
That works. Same goes for any other function - if you have a parm which needs a comma in it, specify it as a separate variable. The above is also more readable IMO. :-)
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Fri Mar 20, 2009 9:01 pm

Ok there is still something slightly odd going on here.

This time I post exact code of my email body line:

Code: Select all

VBSTART
Function GetFolder(Folder)
    Set WShell = CreateObject("WScript.Shell")
    GetFolder = WShell.SpecialFolders(Folder)
    Set WShell = Nothing
End Function
VBEND

VBEval>GetFolder("AppData"),AppData
Let>BLAHAppData=%AppData%\Phil Pendlebury\BLAH
// MessageModal>BLAHAppData

// Determine the decimal placeholder
Let>num=0.1
LibFunc>kernel32,GetNumberFormatA,variablex,0,0,str:num,0,buf,255
MidStr>variablex_5,2,1,DecimalPlaceHolder

Let>app_date=March 21, 2009
Let>versionnum=6.62.175
Let>versionv=%versionnum% born on %app_date%
Let>os_version=OS_VER
Let>BLAH_dir=SCRIPT_DIR
Let>docs_dir=USERDOCUMENTS_DIR
Let>HTTP_TIMEOUT=10

Day>date_var
Month>month_var
Year>year_var
Hour>hour_var
Min>minute_var
Let>time_var=%hour_var%%minute_var%

Let>mail_body=GNF Error Info Attached%CRLF%%CRLF%BLAH Version=%versionnum%%CRLF%OS=%os_version%%CRLF%Documents=%docs_dir%%CRLF%BLAH Folder=%BLAH_dir%%CRLF%App Data=%BLAHAppData%

GNF Error Info Attached

BLAH Version=6.62.175
OS=NT.6.0.6001
Documents=C:\Users\Phil\Documents
BLAH Folder=C:\Program Files (x86)\Phil Pendlebury\BLAH App Data=C:\Users\Phil\AppData\Roaming\Phil Pendlebury\BLAH
It may not be clear but the last line starts with BLAH Folder. There should be a line break and the last line should start with App Data

If you display this as a message it works fine but in the actual email this is how it appears.

The attachment works fine also.
Phil Pendlebury - Linktree

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Fri Mar 20, 2009 10:40 pm

Hi Phil,

There is no actual SMTPSendMail> command in the script you posted.

Please repost your script including the actual SMTPSendMail> command line you're using as that might be important.

And if if those VBScript functions are not required to demo your problem, please remove them as well... as it might make the code easier to test.

If the VBScript stuff must stay... and there are folder requirements, please tell us what folders we might need to create on our machines prior to testing.

Thanks and take care
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Mar 20, 2009 11:35 pm

You are saying the the email body should look like this?
GNF Error Info Attached

BLAH Version=6.62.175
OS=NT.6.0.6001
Documents=C:\Users\Phil\Documents BLAH
Folder=C:\Program Files (x86)\Phil Pendlebury\BLAH
App Data=C:\Users\Phil\AppData\Roaming\Phil Pendlebury\BLAH
The elements of the body email are here:
GNF Error Info Attached%CRLF%%CRLF%BLAH Version=%versionnum%%CRLF%OS=%os_version%%CRLF%Documents=%docs_dir%%CRLF%BLAH Folder=%BLAH_dir%%CRLF%App Data=%BLAHAppData%
Which breaks down into these lines:
GNF Error Info Attached%CRLF%%CRLF%


BLAH Version=%versionnum%%CRLF%
OS=%os_version%%CRLF%
Documents=%docs_dir%%CRLF%
BLAH Folder=%BLAH_dir%%CRLF%
App Data=%BLAHAppData%
So, all of that looks OK except the extra BLAH in front of the folders= line.

So now, what is not happening with your script or your email?
Again, show us the SMTP email line with all of the variables.

Have you stepped through each line and looked at the values of each of the variables on the SMTP line?
Have you used MessageModal to show the value of each of those variables to help you troubleshoot? Be very helpful just before the SMTP line.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Mar 21, 2009 9:08 am

Phil Pendlebury wrote:BLAH Version=6.62.175
OS=NT.6.0.6001
Documents=C:\Users\Phil\Documents
BLAH Folder=C:\Program Files (x86)\Phil Pendlebury\BLAH App Data=C:\Users\Phil\AppData\Roaming\Phil Pendlebury\BLAH

It may not be clear but the last line starts with BLAH Folder. There should be a line break and the last line should start with App Data

If you display this as a message it works fine but in the actual email this is how it appears.
Are you sure your email client isn't just removing line breaks? Outlook has a nasty habit of doing that to me. And not always ALL the line breaks. At the top of the message it warns that it has removed some line breaks. If you click there it restores them. It sometimes only removes some line breaks and I have no idea why or how it decides which ones to remove. Wish it would just leave well alone.

So make sure you're looking at the RAW message. Could just be your email client transposing the message. If you like set the TO address to mine, run it, and I'll take a look at the outcome.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Sat Mar 21, 2009 11:32 am

Hi guys,

Thanks for your help.

I'm afraid this one will not be possible to solve unless someone actually tries using the function.

I say this because:

I know the line is now correct.

The VBScript is important because it shows how I got the BLAHAppData variable.

Basically the last set of %CRLF%%CRLF% in the email body is being ignored. The attachment still works so I know the line is correct.

The only thing that makes any sense at all is what Marcus is saying about Outlook.

I will try in another mail client.

Meanwhile. If anyone wants to test this. Just make a body line with some variable and CRLF and try actually using it in the email function.

:-)
Phil Pendlebury - Linktree

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Sat Mar 21, 2009 2:46 pm

OK guys.

Marcus was right of course...

It was Outlook somehow stripping the CRLF

I viewed the mail in my mobile me account and it looks perfect.

Sorry if I wasted anyone's time.

Hopefully at least some of the info here will be useful to others in future.

:-)
Phil Pendlebury - Linktree

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Mar 21, 2009 3:47 pm

If this is going out in HTML is there any way that using might work? vs. %CRLF% ?

Or can you use VBS to compose the body using VbCrLf or Chr(13) & Chr(10)?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts