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. #7
    Junior Member
    Join Date
    May 2013
    Posts
    11
    Rep Power
    0
    Thank you Administrator for your kind efforts.

    I still have a problem with the file name or path! please have a look to the picture hereunder:

    Fox1.JPG


    for mor details about the problem I faced :

    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 = "D:\TempFile." & CreateObject("scripting.filesystemobject").getextensionname(ThisWorkbook.Name)
        c01 = ThisWorkbook.FileFormat
        'Copy active sheet
        ThisWorkbook.ActiveSheet.Copy
        'Save attachment
        With ActiveWorkbook
            .SaveAs c00, c01   ‘ Here is the problem I faced        
    .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
    Please have a look to the attached file:
    Payroll-1.xlsm
    Last edited by Excel Fox; 07-02-2013 at 07:48 PM. Reason: Code Tags

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
  •