HTML Email (data > 32000 bytes) - Possible VB workaround?

Progress v91d06, XP, Server 2003, Citrix Metaframe, Office 2003

We are trying to build a html email using Outlook com objects. We are loading the full html body into a character variable. When reaching the 32000 byte limit we get the following error...

REPLACE/CONCAT may not result in data > 32000 bytes

I believe this is a Progress limitation so we thought of a VB script but do not have the necessary skills to do this.
Is there another workaround?
Or
Do you have sample code of Progress procedure firing up a VB script?
Upgrading to OpenEdge 10 is not really an option at this time.
 
Is it possible to split the body into multiple variables, and string them together when creating the HTML?

eg:

OutlookObject:CreateHTML(var1 + var2 + ...).

or

OutlookObject:AddHTML(varN).

These are madeup method names, I don't know the com calls, but you get the idea.
 
Thanks for the reply Lee,

Unfortunately the HTMLBody is a property of the MailItem and needs to be written to all in one.

Code:
chMailItem:HTMLBody = vHTMLString.

If I try:

Code:
chMailItem:HTMLBody = vHTMLString1 + vHTMLString2.

It doesn't work.
Besides, I'm not sure if Progress would allow such a transaction (writing > 32000 bytes to a property in one go)?
 
Besides, I'm not sure if Progress would allow such a transaction (writing > 32000 bytes to a property in one go)?

The first suggestion may not work, you are possibly right, but the second one should if there was such a method.

Can the HTMLBody be sourced from a text file?

ie. output HTML to temporary text file, then load that into your object?
 
The temporary text file was one avenue I tried, but I cannot set the property of the object to be a text file.

e.g.

Code:
chMailItem:HTMLBody = C:\mytextfile


I could write the HTML file and attach it, but that doesn't achieve the end product I need.

Also I cannot build the HTMLBody property incrementally like this

Code:
chMailItem:HTMLBody = chMailItem:HTMLBody + "next line"

so it has to be written in one go. This means that writing to a text file doesn't really achieve anything.
 
There is an AddRelatedBodyPart method which allows you to insert graphics etc. into the message (I just looked it up), perhaps you can figure out how to use that.

Failing that, until someone comes up with a good suggestion, or the appropriate method calls, it looks like you will have to send the file as an attachment, or reduce it below the limit.

In the meantime, here is a VBScript Example using Excel - assuming you have Excel available to the program, you could concatenate the cells into the body and send that (or more simply avoid Excel, and pursue your original idea using this example for pointers).

http://www.dicks-clicks.com/excel/olSending.htm

However it's a kludge, and I would have thought there would be an easier workaround for Progress.
 
Adapting

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wss/wss/_cdo_imessage_htmlbody.asp



[Visual Basic]

Dim iMsg As New CDO.Message
' ... .MimeFormatted defaults to True on the new message ...
Dim strHTML As String ' string in which to build up HTML body
' ...
Set iMsg = New CDO.Message
strHTML = "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">" & NL
strHTML = strHTML & "<HTML>"
strHTML = strHTML & " <HEAD>"
strHTML = strHTML & " <TITLE>Sample GIF</TITLE>"
strHTML = strHTML & " </HEAD>"
strHTML = strHTML & " <BODY><p>"

strHTML = strHTML & " <IMG src=""textfile.txt""></p><p>Inline graphics</p>" << Change this line to insert HTML instead

strHTML = strHTML & " </BODY>"
strHTML = strHTML & "</HTML>"

iMsg.HTMLBody = strHTML

iMsg.AddRelatedBodyPart "c:\temp\textfile.txt", "textfile.txt", cdoRefTypeId

iMsg.Send


And alter the IMG line to insert HTML at that position (sorry, I don't know HTML, but I assume you can do that sort of stuff).
 
Ah, I see why I missed that method. The message object you are dealing with there is a CDO message. I think that is the object used when talking directly to Exchange? I am using the Outlook MailItem object to send using Outlook. (sorry, should have been more specific!)

http://msdn.microsoft.com/library/d...y/en-us/vbaol11/html/olmthSend_HV05247742.asp

We have methods of sending large emails using socket sending (smtpmail.p from www.freeframework.org) and other methods using web services to manipulate exchange, but for this application we want to use the tracking facility of Outlook. To do this, we need client side code that creates a MailItem object and sends from the users Outlook session. I will have a look at your XL example and see if I can use that.

Thanks again Lee.
 
In the meantime, here is a VBScript Example using Excel - assuming you have Excel available to the program, you could concatenate the cells into the body and send that (or more simply avoid Excel, and pursue your original idea using this example for pointers).

http://www.dicks-clicks.com/excel/olSending.htm


I have had a look and that is the type of code I have written, but I didn't know how to call it from Progress. I have since put it into a .vbs file which I can run from the command line.

I am probably going to have to write the HTMLBody into a text file and read it into my VBScript. My plan is to write the text file in Progress, then fire up the script passing it the path, read the text file and build the email in my VBScript. I have absolutely zero VBScript experience, though, so figuring out how to read a text in will be another step on my steep learning cure :)
 
Ah, I see why I missed that method. The message object you are dealing with there is a CDO message. I think that is the object used when talking directly to Exchange? I am using the Outlook MailItem object to send using Outlook. (sorry, should have been more specific!)

No, you were quite specific - I just did a MSDN search on HTMLBody and looked at related methods, and (erroneously) assumed they were both accessible to you. Sorry for red herring.:blush1:
 
GOT IT!!

Here is the VBScript to take a file path as an extension and read that file in as the HTMLBody

Code:
If WScript.Arguments.count <> 1 Then
 WScript.echo "Error, invalid arguements passed to Email.vbs"
 WScript.Quit
End If
StrInputFile = WScript.Arguments.Item(0)
 
Dim SafeItem, oItem, Application
Set Application = CreateObject("Outlook.Application")
Set SafeItem = CreateObject("Outlook.MailItem")
Set oItem = Application.CreateItem(0) 'Create a new message
MailItem.Recipients.Add "[EMAIL="somebody@somewhere.com"]somebody@somewhere.com[/EMAIL]"
MailItem.Recipients.ResolveAll
MailItem.Subject = "Testing Email from VBScript"
MailItem.Item.BodyFormat = 2       'olHTMLFormat
MailItem.HTMLBody = ReadTextFile(StrInputFile) 
MailItem.ReadReceiptRequested = True
MailItem.OriginatorDeliveryReportRequested = True
MailItem.Send
 
'******************************************************************************
Function ReadTextFile(strInputFile)
On Error Resume Next
Const FOR_READING = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FileExists(strInputFile) Then
  WScript.Echo "Input text file " & strInputFile & " not found."
  WScript.Quit
End If
Set objTextStream = objFSO.OpenTextFile(strInputFile, FOR_READING)
If objTextStream.AtEndOfStream Then
  WScript.Echo "Input text file " & strInputFile & " is empty."
  WScript.Quit
End If
ReadTextFile = objTextStream.ReadAll
objTextStream.Close
 
End Function

To run from Progress I simply do this:

Code:
OUTPUT TO C:\testing.txt.
DEFINE VARIABLE i AS INTEGER    NO-UNDO.
PUT UNFORMATTED "<HTML><BODY>".
DO WHILE i < 100:
    PUT UNFORMATTED "this is line " i "<BR>".
    i = i + 1.
END.
PUT UNFORMATTED "<\HTML><\BODY>".
OS-COMMAND "C:\EMail.vbs C:\testing.txt".
 
Well there you go ... though you would have thought it would be easier...

something like

ASSIGN chMailItem:HTMLBody = chMailItem:HTMLBody + 'Appended Text'.

(like you suggested eariler)


But that sort of programming is too easy for us Progress programmers.
 
One last try (and suggesting the bleedin' obvious):

Is it not possible to do:

ASSIGN chMailItem:HTMLBody = (chMailItem:HTMLBody + 'Appended text').

Although I understand that will probably reproduce the original overflow error.


Yeah, tried that at the start. Thanks for all your help and advice, but I think I'll use the above VBScript solution. Speed might be an issue, so I'll try to build the EMail soley in Progress first, but if it gets too large, I'll resort to "Plan VB"

Something like

Code:
vHTMLString = vHTMLString + "Next line" NO-ERROR.
IF ERROR-STATUS:ERROR THEN
          RUN ipPlanVB.
 

NADIPINENI

New Member
I got this error because of large bar i kept in a report . after i removed that, I m done. so make sure to remove any large background areas for good formatting. or split them into smaller ones.

Thanks
Sreedhar
progress.gif
 
Top