0

I've got an email processing agent. It copies the body of the email into a document's rich text field. If there are any embedded links in the email I want to process that embedded link and extract the url. I started playing around with MIMEEntity but nothing came of it. Any ideas?

thanks clem

================ Hi Rich,

Well here's a more robust explanation of what's going on. I have several Notes apps which deal with email correspondence. An email comes in, a Notes document is created with some meta data (system generated ID, user's email, name, company, status, etc). The email body is added to a 'correspondence' rich text field of the created Notes doc. The app allows for someone on our side to follow up on the email (ask a question, provide some feedback, etc). That response from us is pre-pended to the original email. If the original sender responds with some further information, THAT email is also pre-pended. To do this pre-pending, I do

bodyText = EmailDoc.GetFirstItem("Body").text
textFromNotesDoc = CTdoc.GetFirstItem("Issue").text 

newTextFromNotesDoc = bodyText + <some stuff> + textFromNotesDoc

I then do a replace.

This worked perfectly fine for years. However, recently users have been sending in emails containing embedded links. Of course anything like that is lost when I do the NotesDocument.GetFirstItem().Text. So I've been trying to think of a way to capture the embedded link. The other day it occurred to me that if I could read the html, I could find and extract the url and simply add it to text. I thought maybe using NotesMIMEEntity would allow me to read through the body field and find the url but that's not working.

Clem

Clem
  • 395
  • 1
  • 13
  • Check out this post of HTML to RTF conversion: http://stackoverflow.com/questions/150208/how-do-i-convert-html-to-rtf-rich-text-in-net-without-paying-for-a-component – Paul Andrew Jun 13 '16 at 14:22
  • How do you copy the body into a rich text field? Better yet, why? Have you tried reading it from the original? Is the original data in a MIME message, or is it a rich text message? – Richard Schwartz Jun 13 '16 at 17:18
  • Is the email coming in as a MIME email? Or is it being converted to rich text by the router before your code ever gets to touch it? You can tell by examining it in the mail-in database and looking at doc properties and checking the field type for Body item, which will either be 'Rich Text' or 'MIME Part'.. And what is your NotesSession.ConvertMIME setting? – Richard Schwartz Jun 14 '16 at 16:58
  • BTW, the storage format for inbound messages is controlled by a setting in the mail-in database doc in the NAB labeled 'Internet message format'. (I'm assuming this is a mail-in database even though you didn't say. If it's a personal mailbox, the same setting exists, but the label says "Format preference for incoming mail". (The wording of the choices is also slightly different, but the meanings are the same.) – Richard Schwartz Jun 14 '16 at 17:03
  • It's not a mail-in db. I created a Notes user and pointed 'their' mail. But set the 'Format preference for incoming mail' to 'prefers MIME' but that didn't make a difference -- the email is coming in with the body field as RichText. – Clem Jun 14 '16 at 19:43
  • Sorry for the incoherent comment. ;-) I tried to edit it but someone came into my office and now it's like it on the internet for perpetuity! I meant to say that I set the setting to 'prefers MIME' but the email still came in with the Body field as RT. I did a reload config on the router but maybe it needs a restart for this to work. I'll keep working on it. But thanks for the tip! – Clem Jun 14 '16 at 19:59
  • I see that you have a solution below, but I want to know: did you have NotesSession.ConvertMIME set to false? Without that, a MIME body would be converted to rich text in memory as soon as your agent accesses the NotesDocument, so by the time you access the Body item it's already rich text. If you set it to false at the start of the session, you should have been able to access the Body as a NotesMIMEEntity. – Richard Schwartz Aug 08 '16 at 17:42

1 Answers1

0

The solution is to NOT NotesDocument.GetFirstItem().Text. Just simply take the email coming in and prepend the body field to the discussion RT field. I add tags to the email going out so that I know if the person responding included the previous conversation. That took a little work to figure out but by using NotesRichTextNavigator and related classes, I'm able to deal with that.

clem

Clem
  • 395
  • 1
  • 13