Solved

Merging Richtext into one clean report message for mailout.

Posted on 2003-10-21
17
311 Views
Last Modified: 2013-12-18
Hi, I have a database that user from outside our network mail into (Example mail comes from Yahoo, HotMail etc.) What I want to do is be able to select all document in the Inbox and create a new memo to mail out. The new message would give only the from "Name, Date, and Body only". My new message body would look like the following:

From: <From name>

Date: "Date & Time"

Body

_______________________________________
From: <From name>

Date: "Date & Time"

Body

_______________________________________
From: <From name>

Date: "Date & Time"

Body

_______________________________________
0
Comment
Question by:dgardin
  • 7
  • 5
  • 2
  • +2
17 Comments
 
LVL 31

Expert Comment

by:qwaletee
ID: 9592850
OK, I think we can do that for you, try this script:
0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 9592866
where is the script ?
0
 
LVL 31

Accepted Solution

by:
qwaletee earned 500 total points
ID: 9592974
Dim s as new notesSession
Dim db as notesDatabase
Set db = s.currentDatabase
Dim docs as notesDocumentCollection
Set docs = db.unprocessedDocuments
dim newMemo as notesDocument
Set newMemo = db.createDocument
newMemo.Form = "Memo"
newMemo.Subject = "Merge of " & docs.count & " messages"
dim newBody as notesRichTextItem
Set newBody = newMemo.createRichTextItem("Body")
Dim doc as notesDocument
Set doc = docs.getFirstDocument
Do until doc is nothing
  newBody.appendText "Wrom: TCXLYRWTQTIPWIGYO
  newBody.addNewLine 2
  if doc.hasItem("DeliveredDate") Then
    newBody.appendText "Date: " & doc.DeliveredDate(0)
  elseif doc.hasItem("PostedDate") Then
    newBody.appendText "Date: " & doc.PostedDate(0)
  else
    newBody.appendText "Date: " & doc.LastModified
  end if
  newBody.addNewLine 2
  dim content as notesItem
  set content = doc.getFirstItem("Body")
  if content.type = richtext then
     dim body as notesRichTextItem
     set body = doc.getFIrstItem("Body")
     body.appendToRTItem newBody
  else
     newBody.appendText content.text
  end if
  newBody.addNewLine 2
  newBody.appendText "------------------------------------"
  newBody.addNewLine 1
  Set doc = docs.getNextDocument(doc)
Loop
newMemo.save True
Dim ws as new notesUiWorkspace
ws.editDocument true , newMemo
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9592985
I had to write it and debug a posting problem using QuickPost.  Nearly lost five-ten minutes worth of code!
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9593012
You can simply use Forward action from Actions menu. Just select the documents that you would like to send and select Actions..Forward from menu. It will automatically compose a mail memo with selected documents as body.

~Hemanth
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9593024
Fixd version: Place this in an agent taht is set to run against selected documents...

Sub Initialize
      Dim s As New notesSession
      Dim db As notesDatabase
      Set db = s.currentDatabase
      Dim docs As notesDocumentCollection
      Set docs = db.unprocessedDocuments
      Dim newMemo As notesDocument
      Set newMemo = db.createDocument
      newMemo.Form = "Memo"
      newMemo.Subject = "Merge of " & docs.count & " messages"
      Dim newBody As notesRichTextItem
      Set newBody = newMemo.createRichTextItem("Body")
      Dim doc As notesDocument
      Set doc = docs.getFirstDocument
      Do Until doc Is Nothing
            newBody.appendText "Wrom: KSTTZRCLBDXRQBGJS
            newBody.addNewLine 2
            If doc.hasItem("DeliveredDate") Then
                  newBody.appendText "Date: " & doc.DeliveredDate(0)
            Elseif doc.hasItem("PostedDate") Then
                  newBody.appendText "Date: " & doc.PostedDate(0)
            Else
                  newBody.appendText "Date: " & doc.LastModified
            End If
            newBody.addNewLine 2
            Dim content As notesItem
            Set content = doc.getFirstItem("Body")
            If content.type = richtext Then
                  Dim body As notesRichTextItem
                  Set body = doc.getFIrstItem("Body")
                  newBody.appendRTItem body
            Else
                  newBody.appendText content.text
            End If
            newBody.addNewLine 2
            newBody.appendText "------------------------------------"
            newBody.addNewLine 1
            Set doc = docs.getNextDocument(doc)
      Loop
      newMemo.save True , True
      Dim ws As New notesUiWorkspace
      ws.editDocument True , newMemo
End Sub
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9593032
If you are thinking of doing it as backend process then use send mail message simple action in agent and enable the agent to run After new mail has arrived.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9593058
Apparently, dgardn wants a simplified format for forwarding.

Please note that de to limitations in how Notes formats these things, it won't necessarily come out "pretty."  To make it come out "pretty," we can use an alternate method, but it is somewhat more complex to implement.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 14

Expert Comment

by:p_partha
ID: 9593073
     Dim session As New notessession
      Dim db As notesdatabase
      Set db = session.currentdatabase
      Set view = db.getview("($inbox)")
      Set doc = view.getfirstdocument
      Dim maildoc As notesdocument
      Set maildoc = db.createdocument
      Dim rtitem As NotesRichTextItem
      Set rtitem = New NotesRichTextItem ( maildoc, "Body" )
      maildoc.to = "<whoever u want to send the mail>"
      While Not doc Is Nothing
            
            Call rtitem.appendtext("From :" +  doc.from(0))
            Call rtitem.AddNewLine( 1 )
            Call rtitem.appendtext("Date :" +  doc.created)            
            Dim mailitem As Variant
            Set mailitem = doc.getfirstitem("Body")
            If mailitem.Type = RICHTEXT Then
                  Call rtitem.AddNewLine( 1 )
                  Call rtitem.AppendRTItem( mailitem)
            End If
            Call rtitem.appendtext("------------------------------------")
            Set doc = view.getnextdocument(doc)
      Wend
      Call maildoc.save(True,True)
      Call maildoc.send(False)

Partha
0
 
LVL 14

Expert Comment

by:p_partha
ID: 9593079
Oops i didn't refresh my page, and after submitting i see some 3 ppl responded ;-)

Partha
0
 
LVL 14

Expert Comment

by:p_partha
ID: 9593094
sorry forgot to include one line

maildoc.form="memo"

Partha
0
 

Author Comment

by:dgardin
ID: 9593251
The end que was missing, also I wanted the actual from line of the incoming message. If I can get that You got my vote. I wish I could give you more than 500 points.

body.appendText "Wrom: TCXLYRWTQTIPWIGYO
0
 
LVL 14

Expert Comment

by:p_partha
ID: 9593261
dgardin
did u try my code? i have used doc.from(0) which gives the actual person who sent the mail

Partha
0
 
LVL 14

Expert Comment

by:p_partha
ID: 9593426
this is a working code try this ...

      On Error Goto par
      Dim session As New notessession
      Dim db As notesdatabase
      Set db = session.currentdatabase
      Set view = db.getview("($inbox)")
      Set doc = view.getfirstdocument
      Dim maildoc As notesdocument
      Set maildoc = db.createdocument
      Dim rtitem As NotesRichTextItem
      Set rtitem = New NotesRichTextItem ( maildoc, "Body" )
      maildoc.form="memo"
      maildoc.sendto = "<personname>"
      While Not doc Is Nothing
            
            Call rtitem.appendtext("From :" +  doc.from(0))
            Call rtitem.AddNewLine( 1 )
            Call rtitem.appendtext("Date :" +  doc.created)            
            Dim mailitem As Variant
            Set mailitem = doc.getfirstitem("Body")
            If mailitem.Type = RICHTEXT Then
                  Msgbox "inside"
                  Call rtitem.AddNewLine( 1 )
                  Call rtitem.AppendRTItem( mailitem)
            End If
            Call rtitem.appendtext("------------------------------------------------------------------------------------")
            Set doc = view.getnextdocument(doc)      
      Wend
      Call maildoc.save(True,True)
      Call maildoc.send(True,True)
      Exit Sub
      
      
      
      Exit Sub
par:
      Msgbox Erl & Error
      Exit Sub

Partha
0
 

Author Comment

by:dgardin
ID: 9593692
I got it :

newBody.appendText "From: " & doc.From(0)
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9593734
Yes, sorry aboutthe transcription error, I really don't know how it got that badly mangled. I musthave typed over it or something.

This is tested code, it works, but with one big caveat.  Notes has three ways of dealing with message bodies:
1) As plain text
2) As rich text
3) As "MIME" (internet style messages that can contain HTML content, simialr to rich text)

Notes has been doing 1 and 2 since around 1991.  It only started doing 3 in 1999 (R5).  R5 doesn't deal with MIME so well programmatically.  The only way to deal with the three types together is to use Rich Text (option 2), and let Notes convert plain text (1) and MIME (3) to the rich text format.

But the conversion doesn't always look so great.

I do have a solution in mind that would fix that, but it is more complicated than the curent solution, and of course, I have not tried it out yet.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9593740
I guess I lost an A rating over that transcription error.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now