+ Reply to Thread
Results 1 to 2 of 2

Email Workbook through Lotus Notes

  1. #1
    Registered User
    Join Date
    07-24-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    49

    Email Workbook through Lotus Notes

    Hello,

    The following code triggers an email to my lotus notes. The code works great and shoots an email but does not attach the excel workbook, it just sends an email without any attachment.

    Can someone help. FYI, I have got this code from the internet just not sure exact website.


    Sub EmailFile()
    ' Declare Variables for file and macro setup

    Dim UserName As String
    Dim MailDbName As String
    Dim Maildb As Object
    Dim MailDoc As Object
    Dim AttachME As Object
    Dim Session As Object
    Dim EmbedObj1 As Object

    ' 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"
    MailDoc.SendTo = "trading.algo@bng.com"


    MailDoc.Subject = "Nih New Project"
    MailDoc.Body = _
    "Attached is a new Nih Project Request. Please let me know when it has been setup."

    ' Select Workbook to Attach to E-Mail

    MailDoc.SaveMessageOnSend = True
    attachment1 = "G:\BmIT\BM Projects 2004\FUT- Futures\RTS\Dupli.xlsx" ' Required File Name

    If attachment1 <> "" Then
    On Error Resume Next
    Set AttachME = MailDoc.CREATERICHTEXTITEM("attachment1")
    Set EmbedObj1 = AttachME.embedobject(1454, "attachment1", " G:\BmIT\BM Projects 2004\FUT- Futures\RTS\Dupli.xlsx ", "") '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

    errorhandler1:

    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set AttachME = Nothing
    Set Session = Nothing
    Set EmbedObj1 = Nothing

    With Application
    .ScreenUpdating = True
    .DisplayAlerts = True
    End With

    End Sub


    Thanks in advance....

  2. #2
    Registered User
    Join Date
    07-24-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    49

    Re: Email Workbook through Lotus Notes

    bump it up !

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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