Using MAPI to send attachments from memory, or deleting temp attachment files.

  • Thread starter ThisIsARequiredField
  • Start date Views 605
Not open for further replies.


I have an application that has large blocks of data that exist only in memory (not on the file system) that must be sent as attachments in email messages. I'm not sure what the best way to do this is.

I am currently using Simple MAPI (with C++) to send emails with attachments, creating temporary files to hold the data and attaching those files to the emails. I have to create temporary files because MapiFileDesc specifies a path name, not the data itself. I have a few questions:

1) I'd like to delete the temporary files I create as soon as possible after they are used; is there a way, through MAPI (simple or extended) to tell when the mail client (e.g. Outlook) is completely finished using the file, so I know when it's safe to delete? If not, is there a better strategy for this? My current strategy just deletes the oldest files once some maximum amount of disk space is used. This works, but I'd like something cleaner.

2) Is there a way, either through simple MAPI or extended MAPI, to construct an attachment directly from data in memory without having to create a temporary file first?

3) I'm new to MAPI and jumped right in to simple MAPI because it was easy to use (even though it was deprecated). Do one of the other options (extended MAPI or CDO[NTS]) provide the ability to attach data from memory to an email?

Also, on a different topic, I am having a really hard time finding information about using CDO/CDONTS. Is there a set of reference documentation or examples somewhere (C++ would be ideal but I'll take what I can get)?

Not open for further replies.

Similar threads