Solved

Merging Richtext into one clean report message for mailout.

Posted on 2003-10-21
17
314 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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
 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

785 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