Once you want to add attachment to the message, you will
use this method. It takes file from your disk, and puts it
in appropriate place in the message.
Please note that wodMailbox may do significant changes
on your message if you use this method. First, it has to
determine if message is already multipart. If not, it will
create appropriate headers (by default this will be
multipart/mixed'), choose boundary to use for
parts separation, create new message part, and add encoded
attachment to the message.
Using this scenario, it's easy for you to create new
message, with a simple line like this:
Don't forget to call Update method to
actually write changed message contents back to
Since in above sample we didn't specify encoding to
use, wodMailbox uses Base64 as default.
What happens to the message file after Add is called?
wodMailbox creates temporary file, adds one header
with encoding name, and after one empty line just writes
encoded data. After that, that part is just inserted using
method for adding new message parts. We can do this,
because Attachments.Add generates regular mail message with
headers, empty line and some body.
As you might have noticed so far, we didn't specify
filename in attachment part. Also, we didn't specify
any additional data that can be used by mail client to
determine where and how to save this file (except for how
to decode it). It would be good idea to add this info
manually. This is pretty simple, since Add method returns
reference to new part that was just created. Adding new
headers is easy:
Dim part As Message
Set part =
part.Headers.Add "Content-Type", "application/x-zip-compressed"
part.Headers.Add "Content-Disposition", "attachment;
(for above sample to work your mailbox must contain at
least one message)
When Add method is used, file is encoded internally and
stored to temporary file. wodMailbox will hold this file
opened as long as mailbox is valid and not updated. Once
you call Update method, mailbox file is recreated,
temporary file is moved to mailbox, and temporary file gets
For a list of most common mime types, click here.