Lotus Notes to display send message

janz

Registered User.
Local time
Today, 04:07
Joined
Jan 25, 2008
Messages
44
Hi years ago I found some code, on this super forum, that I have adapted to my needs and are using in some applications.
However in my new application I do not want to send the message right away but first display it, for the user to change, if needed.

I looked all over the forum to find a solution however can't find one.
Any body a solution or a push in the right direction? Really need some help.
Code:
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 ATTACHME As Object 'The attachment richtextfile object
    Dim Session As Object 'The notes session
    Dim EMBEDOBJ As Object 'The embedded object (Attachment)
    Dim nSendTo() As Variant 'The array that holds the send to's
    Dim ncc() As Variant 'The array that holds the cc's
    
    'Start a session to notes
    Set Session = CreateObject("Notes.NotesSession")
    'Next line only works with 5.x and above. Replace password with your password
    'Session.Initialize ("password")
    '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 or using above password you can use other mailboxes.
    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 MAILDB.ISOPEN = True Then
          'Already open for mail
     Else
         MAILDB.OPENMAIL
     End If
    'Set up the new mail document
    Set MAILDOC = MAILDB.CREATEDOCUMENT
    MAILDOC.Form = "Memo"
    
    
    'MULTIPLE RECIPITANTS
     'multiple reciptants need to be seperated with a semi colun (;)
    Recipient = IIf(Right(Recipient, 1) = ";", Recipient, Recipient + ";")
     a = 0
     Rep = Recipient
     Do While Right(Rep, 1) = ";"
        a = a + 1
        Rep = Left(Rep, Len(Rep) - 1) 'remove the ;
        Rep = IIf(InStr(1, Rep, ";") > 0, Left(Rep, InStrRev(Rep, ";")), Rep) 'remove to the next ;
    Loop
    ReDim nSendTo(a)
    a = 1
    Do While Right(Recipient, 1) = ";" And Len(Recipient) > 1
        Recipient = Left(Recipient, Len(Recipient) - 1) 'remove the ;
              
         nSendTo(a) = Right(Recipient, Len(Recipient) - InStrRev(Recipient, ";"))
        Recipient = IIf(InStr(1, Recipient, ";") > 0, Left(Recipient, InStrRev(Recipient, ";")), Recipient) 'remove to the next ;
        a = a + 1
    Loop
    MAILDOC.sendto = nSendTo
    
    'MULTIPLE RECIPITANTS END
    
    MAILDOC.Subject = Subject
    MAILDOC.Body = BODYTEXT
    
    'MULTIPLE COPY
    a = 0
    CCrecipient = IIf(Right(CCrecipient, 1) = ";", CCrecipient, CCrecipient + ";")
    Rep = CCrecipient
    Do While Right(Rep, 1) = ";"
        a = a + 1
        Rep = Left(Rep, Len(Rep) - 1) 'remove the ;
        Rep = IIf(InStr(1, Rep, ";") > 0, Left(Rep, InStrRev(Rep, ";")), Rep) 'remove to the next ;
    Loop
    ReDim ncc(a)
    
    a = 1
    Do While Right(CCrecipient, 1) = ";" And Len(CCrecipient) > 1
        CCrecipient = Left(CCrecipient, Len(CCrecipient) - 1) 'remove the ;
        ncc(a) = Right(CCrecipient, Len(CCrecipient) - InStrRev(CCrecipient, ";"))
        a = a + 1
        CCrecipient = IIf(InStr(1, CCrecipient, ";") > 0, Left(CCrecipient, InStrRev(CCrecipient, ";")), CCrecipient) 'remove to the next ;
    Loop
    MAILDOC.CopYto = ncc
    'MULTIPLE COPY END
    
    MAILDOC.SAVEMESSAGEONSEND = SaveIt
    MAILDOC.importance = "0"
    
    
    'Set up the embedded object and attachment and attach it
    If attachment <> "" Then 'multiple attachments need to be seperated with a semi colun (;)
    
     Set ATTACHME = MAILDOC.CREATERICHTEXTITEM("Attachment")
     Dim coun, runner As Long
     Dim aTT As String
     
        coun = 1
        runner = 1
        Do While InStr(runner, attachment, ";", 3) > 0 'count the amount of attachments.
           coun = coun + 1
           runner = InStr(runner, attachment, ";", 3) + 1
        Loop
        runner = 1
        
        'decide if it are multiple files
        If coun > 1 Then 'multiple files
            'give the files one name and pack togather in the location of the first file.
            driplazip = Left(attachment, InStrRev(Left(attachment, InStr(1, attachment, ";") - 1), "\")) & "zippedfiles.zip"
            On Error Resume Next
                Kill driplazip 'delete any existing file by this name
            On Error GoTo 0

            'add the files
            Do While coun > 0
                dripla = Mid(attachment, runner, IIf(InStr(runner, attachment, ";", 3) = 0, Len(attachment) + 1, InStr(runner, attachment, ";", 3)) - runner)
                runner = InStr(runner, attachment, ";", 3) + 1
                coun = coun - 1
                pietz = "c:\program files\winzip\wzzip -a   " & driplazip & Space(2) & dripla & " , 1"
                Shellwait1 (pietz) ' 'hold program until winzip is ready.

             Loop
             
            Set EMBEDOBJ = ATTACHME.EMBEDOBJECT(1454, "", Trim(driplazip), "Attachment")
 
            
        Else 'one file
        
            If zipattachments = True Then
                'pack the one file and give it the original name as zip
                dripla = attachment
                driplazip = Left(attachment, Len(attachment) - 3) & "zip"
                pietz = "c:\program files\winzip\wzzip -a   " & driplazip & Space(2) & dripla & " , 1"
                Shellwait1 (pietz) ' 'hold program until winzip is ready.

                aTT = driplazip
                Set EMBEDOBJ = ATTACHME.EMBEDOBJECT(1454, "", Trim(aTT), "Attachment")
            Else
                aTT = attachment
                Set EMBEDOBJ = ATTACHME.EMBEDOBJECT(1454, "", Trim(aTT), "Attachment")
            
            End If
            

            
        End If
        
               
    End If
    'Send the document
    MAILDOC.PostedDate = Now() 'Gets the mail to appear in the sent items folder
    MAILDOC.send 0, Recipient
    
    'Clean Up
    Set MAILDB = Nothing
    Set MAILDOC = Nothing
    Set ATTACHME = Nothing
    Set Session = Nothing
    Set EMBEDOBJ = Nothing
End Sub
 
Re: Lotus Notes to display send message minimized code

OK maybe I did send a bid too much sloppy code for any body to answer.
I deleted all the fluff and here is the basic code.
Any body an idea on how to "show" this message in LN instead of sending it.
Even good suggestions are welcome!

Code:
Function SendNotesMailmin()

'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 ATTACHME As Object 'The attachment richtextfile object
    Dim Session As Object 'The notes session
    Dim EMBEDOBJ As Object 'The embedded object (Attachment)
    Dim nsenDTo() As Variant 'The array that holds the send to's
    Dim nCC() As Variant 'The array that holds the cc's
    
    'Start a session to notes
    Set Session = CreateObject("Notes.NotesSession")
    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 MAILDB.ISOPEN = True Then
          'Already open for mail
     Else
         MAILDB.OPENMAIL
     End If
    'Set up the new mail document
    Set MAILDOC = MAILDB.CREATEDOCUMENT
    MAILDOC.Form = "Memo"
    
    MAILDOC.sendto = "john.doe@microsoft.com"
    MAILDOC.Subject = "Hi this is the subject line"
    MAILDOC.Body = "hi this is the body text"
    MAILDOC.CopYto = "johncopy.doe@microsoft.com"
    MAILDOC.SAVEMESSAGEONSEND = True
    MAILDOC.importance = "0"
    
 
               
    'Send the document
    MAILDOC.PostedDate = Now() 'Gets the mail to appear in the sent items folder
    MAILDOC.send 0, Recipient
    
    'Clean Up
    Set MAILDB = Nothing
    Set MAILDOC = Nothing
    Set ATTACHME = Nothing
    Set Session = Nothing
    Set EMBEDOBJ = Nothing
End Function
 

Users who are viewing this thread

Back
Top Bottom