Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Make a lotus notes email visible after vba compilation so it can be manually edited and sent by the user

Posted on 2006-05-16
10
Medium Priority
?
1,067 Views
Last Modified: 2013-12-18
Hi Lotus experts!

Using the MS Outlook object model it's possible to display a precompiled email by setting the MailItem's visible property to True, so the user can then preview the email and edit it before manual desptach

I'm trying to achieve the same thing in for notes.  Is this possible ?  Here's my code below

Function fcnSendEmailByLotusNotes(strTo As String, strTitle As String, strBody As String, Optional strAttach As String = vbNullString)
'**********************************************************************************************************
' Author:                       JG
' Purpose:                     Send an email by Lotus Notes
' Date Written:              16/May/2006
' Amendment History:     <None>
'**********************************************************************************************************
 
'Declare Variables
Dim notesdb As Object
Dim notesdoc As Object
Dim notesrtf As Object
Dim notessession As Object
 
 Const EMBED_ATTACHMENT = 1454

On Error GoTo Err_fcnSendEmailByLotusNotes

   

    'Define Variables
        Set notessession = CreateObject("Notes.Notessession")
        Set notesdb = notessession.getdatabase("", "")

    'Open Email
        Call notesdb.openmail

    'Build Email
        Set notesdoc = notesdb.createdocument
        Call notesdoc.replaceitemvalue("Sendto", strTo)
        Call notesdoc.replaceitemvalue("Subject", strTitle)
        Set notesrtf = notesdoc.createrichtextitem("body")
        Call notesrtf.appendtext(strBody)
        Call notesrtf.addnewline(2)
       
        'Attach attachment
        If strAttach <> vbNullString Then
            notesrtf.EmbedObject EMBED_ATTACHMENT, "", strAttach
        End If

       
        'Call notesdoc.Send(False)
        notesdoc.Visible = True      '<----- This line doesn't appear to do anything!! How can I make notes display the email ???

    'End Notes Session
        Set notessession = Nothing

Exit_fcnSendEmailByLotusNotes:
    Exit Function

Err_fcnSendEmailByLotusNotes:
    MsgBox Err.Description
    Resume Exit_fcnSendEmailByLotusNotes

End Function



0
Comment
Question by:Natchiket
  • 5
  • 4
10 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16688926
To make the mail visible, Notes will have to be loaded completely and I suppose you don't intend to do that. In any case, Notes needs to know the form to use to display the mail, so you need to tell that:
        Call notesdoc.replaceitemvalue("Form", "Memo")

If you want to start Notes, use the EditDocument-method of NotesUIWorkspace to display the document:
    Dim ws As New NotesUIWorkspace ' if that works from COM...
    ws.EditDocument False, notesdoc, True
0
 
LVL 17

Author Comment

by:Natchiket
ID: 16688949
OK yes notes is already running

I inserted the line

Call notesdoc.replaceitemvalue("Form", "Memo")

but nothing happened
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16689049
And the other two lines?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 17

Author Comment

by:Natchiket
ID: 16689117
I get 'Invalid use of New Keyword'  for the line
Dim ws As New NotesUIWorkspace

When i tried

Dim ws As NotesUIWorkspace
....
Set ws = New NotesUIWorkspace

Same error again

But notes is already running so do I need to instantiate a new workspace ?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16689602
Yes, you would have to instantiate it, but 1) it is not a new workspace, and 2) "This class is not supported in COM." according to the Help...

Set ws = CreateObject("Notes.NotesUIWorkspace")
0
 
LVL 17

Author Comment

by:Natchiket
ID: 16689905
Great thanks sjef_bosman, just one small fly in the ointment: the body text is missing, any idea how I can bring it back? Here is the code as it stands

Function fcnSendEmailByLotusNotes(strTo As String, strTitle As String, strBody As String, Optional strAttach As String = vbNullString)
'**********************************************************************************************************
' Author:                       JG
' Purpose:                     Send an email by Lotus Notes
' Date Written:              16/May/2006
' Amendment History:     <None>
'**********************************************************************************************************
 
'Declare Variables
Dim notesdb As Object
Dim notesdoc As Object
Dim notesrtf As Object
Dim notessession As Object
Dim ws As Object

 
 Const EMBED_ATTACHMENT = 1454

On Error GoTo Err_fcnSendEmailByLotusNotes

   

    'Define Variables
        Set notessession = CreateObject("Notes.Notessession")
        Set notesdb = notessession.getdatabase("", "")

    'Open Email
        Call notesdb.openmail

    'Build Email
        Set notesdoc = notesdb.createdocument
        Call notesdoc.replaceitemvalue("Sendto", strTo)
        Call notesdoc.replaceitemvalue("Subject", strTitle)
        Set notesrtf = notesdoc.createrichtextitem("body")
        Call notesrtf.appendtext(strBody)
        Call notesrtf.addnewline(2)
       
        'Attach attachment
        If strAttach <> vbNullString Then
             Call notesrtf.addnewline(2)
             notesrtf.EmbedObject EMBED_ATTACHMENT, "", strAttach
        End If

       
       Set ws = CreateObject("Notes.NotesUIWorkspace")
        ws.EDITDOCUMENT True, notesdoc, True


    'End Notes Session
        Set notessession = Nothing

Exit_fcnSendEmailByLotusNotes:
    Exit Function

Err_fcnSendEmailByLotusNotes:
    MsgBox Err.Description
    Resume Exit_fcnSendEmailByLotusNotes

End Function


0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 2000 total points
ID: 16690130
That's not a small fly... More like a condor. I think it'll be very difficult, if not impossible. Actually, the document must be saved in order to get the rich-text field updated. So, if you don't mind saving the document before it is mailed...
    notesdoc.Save True, False
    ws.EditDocument True, notesdoc, True
0
 
LVL 17

Author Comment

by:Natchiket
ID: 16690157
Thanks for your generous help!
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16690291
But be careful: the user might not be too happy with mails in his mail database that have never been sent. Please check where these mails pop up, you might need to set additional fields in order to prevent it to be displayed in certain views or folders.
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16696444
Just a note, you have to set the field ExcludeFromView to "A" or "D" so that you don't end up with 5,000 drafts.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

810 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