logo

New Response

« Return to the blog entry

You are replying to:

    • avatar
    • Steve M
    • Posted on Fri 8 Jan 2010 07:57 AM

    Hi Jake

    I have done something similar to addFileAttachment() in my own email class.

    I was actually creating the attachment to order at run time rather attaching an existing one, so it may not fit your needs but in case it is of use or can be modified I'll explain the idea behind it :

    In the class, the various MIME headers only get put together at the time the 'send' method is called. By this point I've already got my HTML text stored as a stream and the text I want to go in the attachment in another stream. Both streams are properties of the email object. I have an additional string property of the object that has the desired name of the file attachment (textAttachFileName).

    The 'send' method sets the MIME headers for the text & HTML parts in the usual way but then creates a new header and child entity that specifically represent the attachment. In the below code the "textAttachStream" can be any text stream you want and is used as the content of the attachment - you may be able to change this bit to write a byte stream instead if your attachment already exists.

    Hope that makes sense - happy to send more details if needed.

    Thanks for a fantastic blog by the way.

    Steve

    '########################

    'A new child mime entity to hold a file attachment

    Dim header As NotesMIMEHeader

    Dim bodyChild As NotesMIMEEntity

    Set bodyChild = body.CreateChildEntity()

    Set header = bodyChild.createHeader("Content-Type")

    Call header.setHeaderVal("multipart/mixed")

    Set header = bodyChild.createHeader("Content-Disposition")

    Call header.setHeaderVal("attachment; filename=" & textAttachFileName )

    Set header = bodyChild.createHeader("Content-ID")

    Call header.setHeaderVal( textAttachFileName )

    Call bodyChild.SetContentFromText( textAttachStream, textAttachMimeType, ENC_IDENTITY_7BIT)

    '########################

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment: