Results 1 to 10 of 10

Thread: Send Mail Using Lotus Notes With Active Sheet As Attachment Using Lotus Notes

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    Untested...

    Code:
    Sub SendLotusMail()
    
        Dim noSession As Object, noDatabase As Object, noDocument As Object
        Dim obAttachment As Object, EmbedObject As Object
        Dim c00 As String, c01
        
        'path, name and extension for tempfile - change to suit
        c00 = "G:\My documents\TempFile." & CreateObject("scripting.filesystemobject").getextensionname(ThisWorkbook.Name)
        c01 = ThisWorkbook.FileFormat
        'Copy active sheet
        ThisWorkbook.ActiveSheet.Copy
        'Save attachment
        With ActiveWorkbook
            .SaveAs c00, c01
            .Close False
        End With
        
        'Instantiate the Lotus Notes COM's  Objects.
        Set noSession = CreateObject("Notes.NotesSession")
        Set noDatabase = noSession.GETDATABASE("", "")
         'If Lotus Notes is not open then open the mail-part of it.
        If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
         'Create the e-mail and the attachment.
        Set noDocument = noDatabase.CreateDocument
        Set obAttachment = noDocument.CreateRichTextItem("stAttachment")
        Set EmbedObject = obAttachment.EmbedObject(1454, "", c00)
         'Add values to the created e-mail main properties.
        With noDocument
            .Form = "Memo"
            .SendTo = ActiveSheet.Range("E9").Value
            .Subject = ActiveSheet.Range("B2").Value
            .Body = "Message Here"
            .SaveMessageOnSend = True
        End With
         'Send the e-mail.
        With noDocument
            .PostedDate = Now()
            .Send 0, ActiveSheet.Range("E9").Value
        End With
        Kill c00'Delete the temporary file
        Exit Sub
       
    ErrorMsg:
            
        If Err.Number = 7225 Then
            MsgBox "The file cannot be found in the location ", vbOKOnly, "Error"
        
        ElseIf Err.Number = 5 Then
            MsgBox "Please ensure that you are logged in to Lotus Notes", vbExclamation, "Lotus Notes"
    
    
        ElseIf Err.Number = 8965 Then
            MsgBox "User is not logged in or user ID file is in use elsewhere and cannot be modified."
        
        Else
            MsgBox Err.Number & Err.Description
        
        End If
        
    End Sub
    Last edited by Excel Fox; 07-01-2013 at 01:07 PM. Reason: bakerman's suggestion of killing included
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Similar Threads

  1. Replies: 2
    Last Post: 07-02-2013, 02:36 PM
  2. Replies: 6
    Last Post: 06-05-2013, 11:33 PM
  3. Replies: 4
    Last Post: 03-01-2013, 10:48 PM
  4. Outlook Send Mail With Multiple Recipient and CC
    By noobtron in forum Excel Help
    Replies: 2
    Last Post: 10-31-2012, 07:14 PM
  5. Send Lotus Notes Email Using VBA
    By ramakrishnan in forum Excel Help
    Replies: 1
    Last Post: 09-08-2011, 09:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •