• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

How to open a NewMail-Form like in Outlook with LotusNotes

Hi there,

how can I open a new Lotus-Memo-Form from my .net application like i do with outlook. I want an empty Form with the subject and body prefilled. Furthermore, the body must be able to display html-content like a table.

I was able to send a mail through Lotus but without displaying a form prior.

Can anyoine help me? Thanks in advance.
Sascha
0
srexp
Asked:
srexp
  • 6
  • 5
1 Solution
 
mbonaciCommented:
Hi srexp,
I've found this on PlanetSorceCode:

    ' Description:Simple script to send a Lotus Notes email.
    ' By: Steven Jacobs
    '
    '    
    On Error Goto 0: sendLNMail()
    Dim s
    Dim db
    Dim doc
    Dim rtitem
    Dim subj
    Dim bdy
    Dim recips(2)
    'File System Object Decs
    Dim fs
    Dim fName
    Dim path
    Sub sendLNMail()
    On Error Resume Next
    '///////////////////////////////////////
    '     ////////////////////////////////
    'Begin Error/Input Routines
    'Created by Steven Jacobs
    '2004
    '///////////////////////////////////////
    '     ////////////////////////////////
    'Get subject...if no subject, exit sub
    subj = inputbox("Please enter a subject For your mail memo.","Email Subject Text")
    if subj = "" Then
    MsgBox "You need a subject"
    Exit Sub
    End if
    'Get body text...if no body text, exit s
    '     ub
    bdy = inputbox("Please enter text For your body mail memo.","Email Body Text")
    if bdy = "" Then
    MsgBox "You need body text"
    Exit Sub
    End if
    Set fs = createobject("Scripting.FileSystemObject")
    if fs Is Nothing Then
    MsgBox "Could Not Create FileSystemObject",16,"File System Object Error."
    endMe
    Exit Sub
    End if
    fName = inputbox("Please enter the full path For the file","Enter Full Path To File","C:\")
    if fName = "" Then
    MsgBox "Empty Path"
    endMe
    Exit Sub
    End if
    path = fs.GetAbsolutePathName(fName)
    if Not fs.FileExists(path) Then
    MsgBox "File does Not exist In directory you specified"
    endMe
    End if
    '///////////////////////////////////////
    '     ////////////////////////////////
    'End Error/Input Routines
    '///////////////////////////////////////
    '     ////////////////////////////////
    Set s = createobject("Notes.NotesSession")
    if s Is Nothing Then
    MsgBox "Could Not Create A Session Of Notes",16,"Notes Session Error."
    endMe
    Exit Sub
    End if
    'See if we can create the main object (s
    '     ession)
    if Err.Number <> 0 Then
    On Error Goto 0
    MsgBox "Could Not create session 'Lotus Notes' from object"
    Exit Sub
    End if
    Set db = s.getdatabase(s.getenvironmentstring("MailServer",True),s.getenvironmentstring("Mailfile",true))
    'See if we can a handle on the mail file
    '    
    if Err.Number <> 0 Then
    On Error Goto 0
    MsgBox "Could find or Get a handle on the mail file"
    Exit Sub
    End if
    Set doc = db.createdocument
    Set rtitem = doc.createrichtextitem("BODY")
    recips(1) = "xxx@xxx.com"
    recips(2) - "rrr@rrr.com"
    With doc
    .form = "Memo"
    .subject = subj
    .sendto = "<xxx>@xxx.com"
    .copyto = "<yyy>@yyy.com"
    .body = bdy
    .postdate = Date
    End With
    call rtitem.embedobject(1454,"",fName)
    doc.visible = True
    doc.send False
    'if we made it this far, alert the user
    '     the mail memo has been created and sent
    MsgBox "You message has been created and sent." & chr(13) & "Thank you.",64,"Message Sent Notification."
    endMe
    End Sub
    Sub endMe()
    'clean objects/memory
    Set s = nothing
    Set db = nothing
    Set doc = nothing
    Set rtitem = nothing
    Set fs = nothing
    End Sub



Hope this helps,
Marko
0
 
srexpAuthor Commented:
Thanks for your fast response. But my NotesDocument (doc) does not have a property named visible.

End With
    call rtitem.embedobject(1454,"",fName)
    doc.visible = True
    doc.send False
    'if we made it thi

This doesn't work. I'm working with LotusNotes 6.5

Sascha
0
 
mbonaciCommented:
srexp,
if you're using OLE then you can use dialogbox method of NotesUIWorkspace class to display custom form (create it yourself) for the user to fill.

This is definition of DialogBox in Lotus Designer's help (can be found on www.Lotus.com):

flag = notesUIWorkspace.DialogBox( form$ , [autoHorzFit] , [autoVertFit] , [noCancel] , [noNewFields] , [noFieldUpdate] , [readOnly] , [title$] , [notesDocument] , [sizeToTable] , [noOkCancel] , [okCancelAtBottom] )
Parameters
form$
String. The name of the form.
autoHorzFit
Boolean. Optional. Specify True to scale the dialog box horizontally to fit the first layout region or table on the form. Otherwise, the dialog box is not scaled horizontally.
autoVertFit
Boolean. Optional. Specify True to scale the dialog box vertically to fit the first layout layout region or table on the form. Otherwise, the dialog box is not scaled vertically.
noCancel
Boolean. Optional. Specify True to not display the Cancel button. Otherwise, the dialog box contains the Cancel button.
noNewFields
Boolean. Optional. Specify True to not add fields that are on the dialog box form but not on the underlying form to the underlying document. Otherwise, all dialog box fields are passed to the underlying document.
noFieldUpdate
Boolean. Optional. Specify True if to not pass any edits from the dialog box to the underlying document (for example, if you're passing the edits somewhere else in a Queryclose script for the dialog box form). Otherwise, the edits are passed to the underlying form.
readOnly
Boolean. Optional. Specify True to prohibit writing to the dialog box (for example, if you are using the dialog box to display a help screen). Otherwise, the dialog box is read-write. This option makes noCancel true.
title$
String. Optional. A title for the dialog box. Defaults to "Lotus Notes."
notesDocument
NotesDocument. Optional. A document to be opened instead of the current document.
sizeToTable
Note  This parameter is new with Release 5.
Boolean. Optional. Specify True to apply autoHorzFit and autoVertFit to the first table on the form. Otherwise, they are applied to the first layout region on the form.
noOkCancel
Note  This parameter is new with Release 5.
Boolean. Optional. Specify True to not display the OK button. Otherwise, the dialog box contains the OK button. Using this parameter prevents any changes made in the dialog box from being reflected in the current document. Use the RefreshParentNote method if you want changes to be reflected in the current document but don't want an Ok button to display.
okCancelAtBottom
Note  This parameter is new with Release 6.
Boolean. Optional. Specify True to display the OK and/or Cancel buttons side-by-side at the bottom right of the dialog box. If you specify False or omit this parameter, the buttons appear stacked at the top right.
Return value
flag
Boolean. Returns True if the user clicks OK in the dialog box. Returns False if the user clicks Cancel.


Hope this helps,
Marko
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.

 
srexpAuthor Commented:
Thanks. I am using a com interop within VisualStudio 2005. Can I yuse something different?
0
 
mbonaciCommented:
srexp,
I've just tested the code in VB 6.0 and it's working.
If you have problem with "visible" line just comment it, it's nothing important.

Hope this helps,
Marko
0
 
srexpAuthor Commented:
I have tried it to. The code works and sends a mail. But it does not open a MailForm so the user cannot make changes. My application creates an offer mail which contains  the items that needs to bo ordered. I want the user to audit and correct the mail before it is sent.
0
 
Sjef BosmanGroupware ConsultantCommented:
Does it have to be in the Notes client, or can you just use a URL?

    http: //server.domain.com/db.nsf/form?OpenForm

And there is the mailto-option:

    mailto: xx@yy.com&subject="something"
0
 
srexpAuthor Commented:
Thanks for your answer. With the mailto: function it is not possible to pass through html formatted body text. you can only use plain text. But I need to create HTML eMails.
0
 
mbonaciCommented:
srexp,

this Sub will compose new mail in LotusNotes with attachment and wait for the user to edit and send, is this what you're looking for?

Private Sub ComposeNotesMail()
    Dim oSess As Object
    Dim oMailDB As Object
    Dim oMailDoc As Object
    Dim oBody As Object

    Dim ws As Object
    Dim uidoc

    Dim mailsvr
    Dim mailfile

    Set oSess = CreateObject("Notes.NotesSession")

    mailsvr = oSess.GetEnvironmentString("MailServer", True)
    mailfile = LCase(oSess.GetEnvironmentString("MailFile", True))

    Set oMailDB = oSess.GETDATABASE("", "")
    Call oMailDB.open(mailsvr, mailfile)

    If oMailDB.isopen Then
        Set oMailDoc = oMailDB.CREATEDOCUMENT
    Else
        MsgBox "Could not open Notes", 32
    End If

    oMailDoc.subject = "Test mail"
    oMailDoc.Form = "Memo"

    Set oBody = oMailDoc.CREATERICHTEXTITEM("BODY")

    Call oBody.Embedobject(1454, "", "c:\Testattachment.htm")

    Set ws = CreateObject("Notes.NotesUIWorkspace")
    Set uidoc = ws.editdocument(True, oMailDoc, False)

    Set oSess = Nothing
    Set oMailDB = Nothing
    Set oMailDoc = Nothing
    Set ws = Nothing
    Set uidoc = Nothing
End Sub

Hope this helps,
Marko
0
 
srexpAuthor Commented:
Yeahh. That's it. But how can I display HTML formatted Text in the body section? If I put some HTML formatted code in the body property. No text will be displayed.
0
 
srexpAuthor Commented:
Thanks. Now it works.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now