+ Reply to Thread
Results 1 to 1 of 1

Embed image into Lotus Notes with VBA - not using Notes.NotesUIWorkspace

Hybrid View

pmor1503 Embed image into Lotus Notes... 09-11-2014, 11:49 PM
  1. #1
    Registered User
    Join Date
    08-13-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Embed image into Lotus Notes with VBA - not using Notes.NotesUIWorkspace

    I have looked at many posts on this and cant find exactly what I need to do.

    I want to include an image within the body of the email (not an attachment).

    I have VBA code that generally populates the details, eg. email address, names, etc. from cells within Excel, but to make this simple, I have added as strings myself.

    I am able to add an image using HTML/MIME method in a subroutine, but when I include it with a sub that creates text for the body of the email, I get an error.
    If I remove the ("test") from Set htmlbody = doc.CreateMIMEEntity ("test"), it will run without error, but the image is not embedded, just the text.

    This may not be the best way, but it's the closest I have got without using the Notes.NotesUIWorkspace method.

    Any help with this would be great, if it is possible. Or a better way.

    Here is the code. NOTE: It only saves as a draft rather than sending.
    Thanks:

    Sub emailimage()
    
    Const EMBED_ATTACHMENT As Long = 1454
    
        Dim UserName As String, server As String, mailfile As String
        Dim doc As Object
        Dim oItem As Object, oStyle As Object
        Dim Session As Object, db As Object
        Dim emailAddressCell As Range
     '#### IMAGE / HTML DECLARATIONS
        Dim htmlbody As Object
        Dim stream As Object
        Dim strImagePath As String
        Dim mimeImage As Object
        Dim mimeImageHeader As Object
      '####
        
        '-------Creates a notessession Object and provides mail details
        Set Session = CreateObject("Notes.NotesSession")
        Set NUIWorkspace = CreateObject("Notes.NotesUIWorkspace")
        Set db = Session.GETDATABASE("", "")
    
        If Not db.IsOpen Then
            db.OPENMAIL
        End If
        
            '*** MESSAGE ***
        Set doc = db.CREATEDOCUMENT()
        Set oItem = doc.CreateRichTextItem("BODY")
        Set oStyle = Session.CreateRichTextStyle
        
        Call oItem.AppendText("Text part of the body of the email")
        doc.Form = "Memo"
                
        '#### IMAGE/HTML FORMAT CODE
        Dim mimeHTML As Object
        Dim richTextHeader As Object
        Set stream = Session.CreateStream()
         
    '*** SOMETHING UP WITH THIS LINE - IF i REMOVE THE '("test")' PART IT RUNS WITHOUT ERROR - BUT IMAGE DOES NOT SHOW
        Set htmlbody = doc.CreateMIMEEntity ("test")
        Set richTextHeader = htmlbody.CreateHeader("Content-Type")
        Call richTextHeader.SetHeaderVal("multipart/mixed")
          
        Call stream.Open("path\image.jpg")
        Set mimeImage = htmlbody.CreateChildEntity()
        Call mimeImage.SetContentFromBytes(stream, "image/jpeg", ENC_IDENTITY_BINARY)
        Call stream.Close
      '####
            
        doc.SendTo = "Email TO address"
        doc.subject = "attach an image"
        doc.visable = True
        doc.SAVEMESSAGEONSEND = True
        
        doc.save True, False 'Save draft
        'doc.SEND False  ' *** SEND ***
                
        Set doc = Nothing
        Set db = Nothing
        Set Session = Nothing
    
    End Sub
    Last edited by pmor1503; 09-12-2014 at 12:26 AM.

+ 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. Inserting jpg image into lotus notes
    By mangeshp4 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-06-2013, 07:53 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. Embed Image in Lotus Notes Email with VBA
    By soccerkingpilot in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-04-2012, 03:25 PM
  4. Is it possible (lotus notes)VBA
    By TonyforVBA in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2010, 05:56 AM
  5. emailing in Lotus Notes
    By owl527 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2005, 11:05 AM

Tags for this Thread

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