Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lotus notes

Status
Not open for further replies.

Zygor

Technical User
Apr 18, 2001
271
US
I know it's out there...I just can't find it.

I'm trying to create a Lotus Notes e-mail. I want to produce the e-mail and show it to the user, without sending it. He wants to click on the To: and select the recipient. All the code I've found sends it automatically.

Can someone please help me?
 
Zygor

I did this recently in VB6 and it works a treat!

Code:
Public Sub Send(Optional CC As String = "", Optional BCC As String = "", Optional SaveIt As Boolean = False)
    'Set up the objects required for Automation into lotus notes
    Dim Maildb As Object 'The mail database
    Dim UserName As String 'The current users notes name
    Dim MailDbName As String 'THe current users notes mail database name
    Dim MailDoc As Object 'The mail document itself
    Dim Session As Object 'The notes session
    Dim NotesWorkspace As Object 'The notes workspace
    
    Dim sStatus As String
    
    On Error GoTo errSendNotesMail_Catch
    
    'Swap out the ; for , in the recipients list
    If SendTo = "" Then SendTo = "enter_email_address_here@somewhere.com"
    SendTo = Replace(SendTo, ";", ",")
    
    'Start a session to notes
    Set Session = CreateObject("Notes.NotesSession")
    
    'Get the sessions username and then calculate the mail file name
    'You may or may not need this as for MailDBname with some systems you
    'can pass an empty string
    UserName = Session.UserName
    MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
    
    'Open the mail database in notes
    Set Maildb = Session.GETDATABASE("", MailDbName)
    If Not Maildb.ISOPEN Then
        Maildb.OPENMAIL    End If
    
    'Set up the new mail document
    Set MailDoc = Maildb.CREATEDOCUMENT
    With MailDoc
        .Form = "Memo"
        .SendTo = Split(SendTo, ",")
        .CopyTo = Split(CC, ",")
        .BlindCopyTo = Split(BCC, ",")
        .Subject = Subject
        .Body = Body
        .SAVEMESSAGEONSEND = SaveIt
        
        'Send the document
        .PostedDate = Now() 'Gets the mail to appear in the sent items folder
        '.Send False
    End With
    
    'Use the workspace to show the email
    Set NotesWorkspace = CreateObject("Notes.NotesUIWorkspace")
    NotesWorkspace.EditDocument True, MailDoc

errSendNotesMail_Finally:
    
    'Tidy Up
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set Session = Nothing
    Set NotesWorkspace = Nothing
    
    Exit Sub
    
errSendNotesMail_Catch:
    If Err.Number = -2147417851 Then
        'This is an error that was occuring on NotesWorkspace.EditDocument True, MailDoc
        'The email still generates anyway so we are ignoring it
        Resume Next
    Else
        'Unknown error
        WasError = True
        MsgBox Err.Number & ": " & Err.Description
        GoTo errSendNotesMail_Finally
    End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top