Hi,I have a lotusscript programs to read the email from a mail in db. I need to get the richtextitem using this line of code: Set rtitem = doc.GetFirstItem( “Body” )
It works fine for a long time, however, I get problem of reading some of mail in emails. The program crashed due to “Set rtitem = doc.GetFirstItem( “Body” )”, when I use debug to trace the code, I find when the code execute this line, I can not get rtitem, so caused “object varaible not set error” for later codes which using rtitem.
Obviously, the item “Body” is gone for this case, but if I open the mail db, and chose the email document by document property, I can see the “Body” item. Anybody knows why my code can not get richtextitem for that case? I have compared the email document with the emails I can get richtextitem, I can not find any different.
Subject: RE: questions about “Set rtitem = doc.GetFirstItem( “Body” )”
If you want to get the rich text item, you should definitely use ConvertMIME = True (that is the default, though).
However, I don’t think every MIME email necessarily has a body. You have to look at what’s in the MIME parts. Is there any text in the body that you expect to be able to see? What do you see in the body area when you open the memo in your client?
You might just have to check for the case of ‘rti is nothing’ and deal with it. If you’re not losing any information from the memo this way, then it doesn’t matter.
Subject: RE: questions about “Set rtitem = doc.GetFirstItem( “Body” )”
I have added the line of code convertMIME = true, but it is not working. I do can see there is text content in the body when I check the email property box, it is very simple text of one line of text string, not attachment , images. etc.
The email was sent from a project using Perl language, I find the code related to send mail in perl as this:
$smtp->datasend($mail{Body});
I have not found any option so far for the SMTP model, it may be some option there to set the body to Richtext field.
I also tried that email, if I open it in note client and resave it, I have no problem to process it. Because after re-save, the body can be seen as richtext .
The strange thing is that , most of email received are MIME type without problem, only this one sent from Perl which caused my code can not find rti item, and I can see the body item in document property box.
This is the body propety in the document property box:
Subject: RE: questions about “Set rtitem = doc.GetFirstItem( “Body” )”
Then it would appear the MIME data is formatted some way that the GetFirstItem method can’t decode. If you contact Lotus Support they may be able to get it fixed in some future version, but for the present you’ll have to set ConvertMIME=False and use the NotesMIMEEntity class to pull it apart and see what’s in it.
Subject: RE: questions about “Set rtitem = doc.GetFirstItem( “Body” )”
Hi Andre,thanks a lot again, Yes, I can not find why only that MIME part body is not working.
Now, as you suggestion, I am trying to use NoetsMIMEEntity to get the body content, it seems work. these are the part of the codes I tested, please let me know if you have any comments for my modified codes:
In order to make it work, the only thing is that I have to set: s.ConvertMIME = False,
Should I set it back to True after my code? I have never used “s.ConvertMIME = False” before.
If Not doc Is Nothing Then
Stop
' s.ConvertMIME = True
s.ConvertMIME = False
Set parent = doc.GetMIMEEntity()
If parent Is Nothing Then
Set rtitem = doc.GetFirstItem( "Body" )
Messagebox "This is Not a MIME email"
If ( rtitem.Type = RICHTEXT ) Then
plainText = Ucase(doc.subject(0)) & rtitem.Text
Messagebox "Richtext:" + plaintext
End If
Else
Messagebox "this is a MIME email"
plainText = doc.GetItemValue("Subject")(0) & Ucase(parent.ContentAsText)
End If
Subject: RE: questions about “Set rtitem = doc.GetFirstItem( “Body” )”
It might not be a bad idea to set it to True when you’re done, since this is a persistent setting (for the length of your client session) and some code may be assuming it’s got its default value.
Subject: RE: questions about “Set rtitem = doc.GetFirstItem( “Body” )”
Hi Irving,Actually, I do not have that code you posted anywhere in my program, I have never used that code.
The thing is that if it was caused by mimi type, why the other similar emails were not caused problem?
I will check the functions of ConverMIME does, however, if I use that code to differiate the mime type, it may impact the other email which was working fine.
any details ideas about using your codes?
Thanks
This is the content of body field which caused problem:
Subject: RE: questions about “Set rtitem = doc.GetFirstItem( “Body” )”
Are you sure you’re looking at the properties of the exact same document? Did you display the note ID, value of the Form field, and so on, in cases where no Body item was found? There are many different kinds of document in the mail database, not all of them memos, and not all memos necessarily contain a Body field anyway (e.g. this might be missing if they were sent by an agent).
Subject: RE: questions about “Set rtitem = doc.GetFirstItem( “Body” )”
Hi Andre,Lucky get your help again, thanks.
yes, I am sure it is the same mail document by checking the document property box.
This is what I did: there are no mail doc in my test evironment (inbox), then I copied and paste an email from production which was fine in production and run my code in testing envrionment, it is running fine.
Then, I copied another email doc from production which caused problem and pasted to testing evironment, I got eorror when I run my code. Which richtextitem “Body” can not be found. The doc property box shows the Body item on the property of body.
The Data type of Body is “Mime part” as Irving mentioned. However, if this created the problem, why other emails with the same data type without any problem?