+ Reply to Thread
Results 1 to 8 of 8

Sending Excel through email using Lotus Notes

Hybrid View

  1. #1
    mridzuan
    Guest

    Sending Excel through email using Lotus Notes

    Hi everybody,

    This is part of the code for sending email from Excel. I obtained this from Ron De Bruin.

    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)

    With Destwb
    .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
    On Error Resume Next
    With OutMail
    .To = "[email protected]"
    .CC = ""
    .BCC = ""
    .Subject = "This is the Subject line"
    .Body = "Hi there"
    .Attachments.Add Destwb.FullName
    'You can add other files also like this
    '.Attachments.Add ("C:\test.txt")
    .Send 'or use .Display
    End With
    On Error GoTo 0
    .Close SaveChanges:=False
    End With

    'Delete the file you have send
    Kill TempFilePath & TempFileName & FileExtStr

    Set OutMail = Nothing
    Set OutApp = Nothing

    I think the code won't work with Lotus Notes. Can anyone help me with this?

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by mridzuan
    Hi everybody,

    This is part of the code for sending email from Excel. I obtained this from Ron De Bruin.

    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)

    With Destwb
    .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
    On Error Resume Next
    With OutMail
    .To = "[email protected]"
    .CC = ""
    .BCC = ""
    .Subject = "This is the Subject line"
    .Body = "Hi there"
    .Attachments.Add Destwb.FullName
    'You can add other files also like this
    '.Attachments.Add ("C:\test.txt")
    .Send 'or use .Display
    End With
    On Error GoTo 0
    .Close SaveChanges:=False
    End With

    'Delete the file you have send
    Kill TempFilePath & TempFileName & FileExtStr

    Set OutMail = Nothing
    Set OutApp = Nothing

    I think the code won't work with Lotus Notes. Can anyone help me with this?
    Hi,

    the code does specify

    Set OutApp = CreateObject("Outlook.Application")

    so I would doubt that it would.

    Are you aware of 'Notes Forums ?

    perhaps http://www.experts-exchange.com/Appl..._21829026.html

    is what you need?

    or http://www-128.ibm.com/developerworks/lotus/community/

    ---
    Last edited by Bryan Hessey; 01-14-2007 at 10:17 PM.
    Si fractum non sit, noli id reficere.

  3. #3
    mridzuan
    Guest
    I've have this code from http://www.ozgrid.com/forum/showthread.php?t=53713 that will work as I wish:

    Sub sendEmail() 
        Dim oSess As Object 
        Dim Maildb As Object 
        Dim MailDoc As Object 
        Dim oItem As Object 
        Dim flag As Boolean 
        Dim bodyMsg As String 
        Dim WasOpen As Integer 
         
        emailErr = False 
         
        Set oSess = CreateObject("Notes.NotesSession") 
        Set Maildb = oSess.GETDATABASE("", "") 
         
        If Maildb.IsOpen = True Then 
            WasOpen = 1 'Already open for mail
        Else 
            WasOpen = 0 
            Call Maildb.openmail 'This will prompt you for password
        End If 
         
        On Error Goto err_handler 
         
        Set MailDoc = Maildb.CREATEDOCUMENT 
        Set oItem = MailDoc.CREATERICHTEXTITEM("BODY") 
         
         ' Building Message
        bodyMsg = "This email was generated by Cupid V3.0." & vbCrLf & vbCrLf 
        bodyMsg = bodyMsg & "Warning! The attached file contains confidential information. Any unauthorized review, use, or distribution is prohibited. " 
        bodyMsg = bodyMsg & "If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message." 
        With MailDoc 
            .Form = "Memo" 
            .subject = "NIR from " & divContact & " (" & divNumber & ")" 
            .sendto = emailAddress 
            .body = bodyMsg 
            .postdate = Date 
            .SaveMessageOnSend = True 
        End With 
         
         ' Attaching new item file.
        Call oItem.EmbedObject(1454, "", emailPath) 
        MailDoc.visable = True 
         
         ' Sending Message
        MailDoc.send False 
         
    exit_SendAttachment: 
        On Error Resume Next 
        Set oSess = Nothing 
        Set Maildb = Nothing 
        Set MailDoc = Nothing 
        Set oItem = Nothing 
         
         ' Done
        Exit Sub 
         
    err_handler: 
        emailErr = True 
        If Err.Number = 7225 Then 
            MsgBox "File doesn't exist" 
        Else 
            MsgBox Err.Number & " " & Err.Description 
        End If 
        On Error Goto exit_SendAttachment 
    End Sub
    However, I have this small problem. This code sends the email immediately. I wanted to view them first and send them manually. for Outlook, I can use .Display but I don't know the same code to be used for Notes. I would be very grateful if anybody can help.

  4. #4
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by mridzuan
    I've have this code from http://www.ozgrid.com/forum/showthread.php?t=53713 that will work as I wish:

    Sub sendEmail() 
        Dim oSess As Object 
        Dim Maildb As Object 
        Dim MailDoc As Object 
        Dim oItem As Object 
        Dim flag As Boolean 
        Dim bodyMsg As String 
        Dim WasOpen As Integer 
         
        emailErr = False 
         
        Set oSess = CreateObject("Notes.NotesSession") 
        Set Maildb = oSess.GETDATABASE("", "") 
         
        If Maildb.IsOpen = True Then 
            WasOpen = 1 'Already open for mail
        Else 
            WasOpen = 0 
            Call Maildb.openmail 'This will prompt you for password
        End If 
         
        On Error Goto err_handler 
         
        Set MailDoc = Maildb.CREATEDOCUMENT 
        Set oItem = MailDoc.CREATERICHTEXTITEM("BODY") 
         
         ' Building Message
        bodyMsg = "This email was generated by Cupid V3.0." & vbCrLf & vbCrLf 
        bodyMsg = bodyMsg & "Warning! The attached file contains confidential information. Any unauthorized review, use, or distribution is prohibited. " 
        bodyMsg = bodyMsg & "If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message." 
        With MailDoc 
            .Form = "Memo" 
            .subject = "NIR from " & divContact & " (" & divNumber & ")" 
            .sendto = emailAddress 
            .body = bodyMsg 
            .postdate = Date 
            .SaveMessageOnSend = True 
        End With 
         
         ' Attaching new item file.
        Call oItem.EmbedObject(1454, "", emailPath) 
        MailDoc.visable = True 
         
         ' Sending Message
        MailDoc.send False 
         
    exit_SendAttachment: 
        On Error Resume Next 
        Set oSess = Nothing 
        Set Maildb = Nothing 
        Set MailDoc = Nothing 
        Set oItem = Nothing 
         
         ' Done
        Exit Sub 
         
    err_handler: 
        emailErr = True 
        If Err.Number = 7225 Then 
            MsgBox "File doesn't exist" 
        Else 
            MsgBox Err.Number & " " & Err.Description 
        End If 
        On Error Goto exit_SendAttachment 
    End Sub
    However, I have this small problem. This code sends the email immediately. I wanted to view them first and send them manually. for Outlook, I can use .Display but I don't know the same code to be used for Notes. I would be very grateful if anybody can help.
    Hi,

    found on another site was the suggestion
    Set workspace = CreateObject("Notes.NotesUIWorkspace") 
    Call workspace.EDITDOCUMENT(True, MailDoc).GOTOFIELD("Body")
    followed by the comment "then delete the send and the save to sent folder or the save to draft folder...this will just bring it up for you to see"

    but the setup for the mail was a little different to yours.

    does this help you?

    ---

  5. #5
    mridzuan
    Guest
    Don't seem to work. Can you point me to the site so that I can view the whole code?

  6. #6
    mridzuan
    Guest
    It doesn't work. Maybe I'm missing some other codes that related to it. Would be grateful if you could point to me the site where you got the code from so that I can view them and figure it out.

  7. #7
    mridzuan
    Guest
    Actually, I tried it again and it does work. Thanks

  8. #8
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by mridzuan
    Actually, I tried it again and it does work. Thanks
    fantastic, I have failed thus far to locate the site that came from, so was still in 'search' mode, but great to see that you managed to get it working, and thanks for the feedback.

    ---

+ 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