+ Reply to Thread
Results 1 to 7 of 7

Attach workbook from Lotus Notes

Hybrid View

TheCman81 Attach workbook from Lotus... 10-22-2013, 06:20 AM
JOHN H. DAVIS Re: Attach workbook from... 10-22-2013, 08:21 AM
TheCman81 Re: Attach workbook from... 10-22-2013, 10:15 AM
JOHN H. DAVIS Re: Attach workbook from... 10-22-2013, 10:31 AM
TheCman81 Re: Attach workbook from... 10-22-2013, 11:02 AM
TheCman81 Re: Attach workbook from... 10-23-2013, 06:15 AM
JOHN H. DAVIS Re: Attach workbook from... 10-23-2013, 06:16 AM
  1. #1
    Valued Forum Contributor TheCman81's Avatar
    Join Date
    11-06-2012
    Location
    Edinburgh, UK
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    346

    Attach workbook from Lotus Notes

    I've also posted the following question here:

    http://www.mrexcel.com/forum/excel-q...via-excel.html

    I have the following code that send an email from excel but want I want to know is how to update this code to attach ThisWorkbook (I've used ThisWorkbook because I want to send the workbook as it is inc the macro)

    Sub GeorgeHart()
    Dim x As Integer
    Dim UserName As String
    Dim MailDbName As String
    Dim Recipient As Variant
    Dim Maildb As Object
    Dim MailDoc As Object
    Dim AttachME As Object
    Dim Session As Object
    Dim stSignature As String
    With Application
    .ScreenUpdating = False
    .DisplayAlerts = False
    ' Open and locate current LOTUS NOTES User
    Set Session = CreateObject("Notes.NotesSession")
    UserName = Session.UserName
    MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
    Set Maildb = Session.GetDatabase("", MailDbName)
    If Maildb.IsOpen = True Then
    Else
    Maildb.OPENMAIL
    End If
    ' Create New Mail and Address Title Handlers
    Set MailDoc = Maildb.CREATEDOCUMENT
    MailDoc.Form = "Memo"
    stSignature = Maildb.GetProfileDocument("CalendarProfile").GetItemValue("Signature")(0)
    
    ' Select range of e-mail addresses
    Recipient = "email address"
    MailDoc.SendTo = Recipient
    MailDoc.Subject = "Test"
    MailDoc.Body = ""
    MailDoc.SaveMessageOnSend = True
    MailDoc.PostedDate = Now()
    On Error GoTo errorhandler1
    MailDoc.SEND 0, Recipient
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set Session = Nothing
    .ScreenUpdating = True
    .DisplayAlerts = True
    End With
    errorhandler1:
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set Session = Nothing
    End Sub
    Excel Guru in the making

    <----------If the question has been answered to your satisfication please click the Add Repuation star to the left

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Attach workbook from Lotus Notes

    I think you would have to save a copy first and then call the second macro?

    Change the Path to the one you are using.
    Sub TheCman81()
    Dim wbk As Workbook
    Dim y As String
    Set wbk = ActiveWorkbook
    y = wbk.Name
    wbk.SaveAs "new attachment"
    Workbooks.Open y
    call TheCman81b
    End Sub
    Sub TheCman81b()
    Dim x As Integer
    Dim UserName As String
    Dim MailDbName As String
    Dim y As String
    Dim Attachment1 As String
    Dim Recipient As Variant
    Dim Maildb As Object
    Dim MailDoc As Object
    Dim AttachME As Object
    Dim EmbedObj1 As Object
    Dim Session As Object
    Dim stSignature As String
    With Application
    .ScreenUpdating = False
    .DisplayAlerts = False
    y = "new attachment"
    ' Open and locate current LOTUS NOTES User
    Set Session = CreateObject("Notes.NotesSession")
    UserName = Session.UserName
    MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
    Set Maildb = Session.GetDatabase("", MailDbName)
    If Maildb.IsOpen = True Then
    Else
    Maildb.OPENMAIL
    End If
    ' Create New Mail and Address Title Handlers
    Set MailDoc = Maildb.CREATEDOCUMENT
    MailDoc.Form = "Memo"
    stSignature = Maildb.GetProfileDocument("CalendarProfile").GetItemValue("Signature")(0)
    
    ' Select range of e-mail addresses
    Recipient = "email address"
    MailDoc.SendTo = Recipient
    MailDoc.Subject = "Test"
    MailDoc.Body = ""
    MailDoc.SaveMessageOnSend = True
    Attachment1 = "D:\Common\data\IBMMAIN\" & y & ".xls" ' Required File Name
    If Attachment1 <> "" Then
    On Error Resume Next
    Set AttachME = MailDoc.CREATERICHTEXTITEM("attachment1")
    Set EmbedObj1 = AttachME.EmbedObject(1454, "attachment1", "D:\Common\data\IBMMAIN\" & y & ".xls", "") 'Required File Name
    On Error Resume Next
    End If
    MailDoc.PostedDate = Now()
    On Error GoTo errorhandler1
    MailDoc.SEND 0, Recipient
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set AttachME = Nothing
    Set Session = Nothing
    Set EmbedObj1 = Nothing
    .ScreenUpdating = True
    .DisplayAlerts = True
    End With
    errorhandler1:
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set AttachME = Nothing
    Set Session = Nothing
    Set EmbedObj1 = Nothing
    End Sub

  3. #3
    Valued Forum Contributor TheCman81's Avatar
    Join Date
    11-06-2012
    Location
    Edinburgh, UK
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    346

    Re: Attach workbook from Lotus Notes

    Thanks for responding. I want to avoid the user saving a copy first as this will be used by 100+ people and they can send updates of there spreadsheet 10+ times a day and also the required file name will be different for each user (they will be using a laptop in the field and not office based)

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Attach workbook from Lotus Notes

    I don't know if this will work but you can try too attach a copy directly from the path. Since your active file is only a copy.

    Sub TheCman81b()
    Dim x As Integer
    Dim UserName As String
    Dim MailDbName As String
    Dim Attachment1 As String
    Dim Recipient As Variant
    Dim Maildb As Object
    Dim MailDoc As Object
    Dim AttachME As Object
    Dim EmbedObj1 As Object
    Dim Session As Object
    Dim stSignature As String
    With Application
    .ScreenUpdating = False
    .DisplayAlerts = False
    ' Open and locate current LOTUS NOTES User
    Set Session = CreateObject("Notes.NotesSession")
    UserName = Session.UserName
    MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
    Set Maildb = Session.GetDatabase("", MailDbName)
    If Maildb.IsOpen = True Then
    Else
    Maildb.OPENMAIL
    End If
    ' Create New Mail and Address Title Handlers
    Set MailDoc = Maildb.CREATEDOCUMENT
    MailDoc.Form = "Memo"
    stSignature = Maildb.GetProfileDocument("CalendarProfile").GetItemValue("Signature")(0)
    
    ' Select range of e-mail addresses
    Recipient = "email address"
    MailDoc.SendTo = Recipient
    MailDoc.subject = "Test"
    MailDoc.Body = ""
    MailDoc.SaveMessageOnSend = True
    Attachment1 = "D:\Common\data\YOUR MACRO PATH AND FILE NAME.xls" ' Required File Name
    If Attachment1 <> "" Then
    On Error Resume Next
    Set AttachME = MailDoc.CREATERICHTEXTITEM("attachment1")
    Set EmbedObj1 = AttachME.EmbedObject(1454, "attachment1", "D:\Common\data\YOUR MACRO PATH AND FILE NAME.xls", "") 'Required File Name
    On Error Resume Next
    End If
    MailDoc.PostedDate = Now()
    On Error GoTo errorhandler1
    MailDoc.SEND 0, Recipient
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set AttachME = Nothing
    Set Session = Nothing
    Set EmbedObj1 = Nothing
    .ScreenUpdating = True
    .DisplayAlerts = True
    End With
    errorhandler1:
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set AttachME = Nothing
    Set Session = Nothing
    Set EmbedObj1 = Nothing
    End Sub

  5. #5
    Valued Forum Contributor TheCman81's Avatar
    Join Date
    11-06-2012
    Location
    Edinburgh, UK
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    346

    Re: Attach workbook from Lotus Notes

    Thanks for your help but this just sends a blank email

  6. #6
    Valued Forum Contributor TheCman81's Avatar
    Join Date
    11-06-2012
    Location
    Edinburgh, UK
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    346

    Re: Attach workbook from Lotus Notes

    Just for an update, I adapted a vba script which I found here which works perfect for me

    http://www.rondebruin.nl/win/section1.htm

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Attach workbook from Lotus Notes

    Glad to hear you found a solution.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Sending workbook through Lotus notes
    By Sibrulotte in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-24-2013, 03:06 AM
  2. Help - Attach an image from the userform into the body of an email in lotus notes
    By dragontm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-12-2013, 05:35 AM
  3. Help! Macro to Generate email in Lotus Notes and automatically attach a file
    By elpollo87 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-27-2012, 10:19 AM
  4. Attach file to Lotus Notes without sending
    By pclive in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-10-2010, 04:49 PM
  5. Attach HTM file to Lotus Notes Mail
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-06-2009, 10:31 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1