Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Ssimple MAPI send with attachments inserts spaces (http://www.outlookbanter.com/outlook-vba/91034-ssimple-mapi-send-attachments-inserts.html)

Mark Smith[_2_] June 1st 09 02:40 PM

Ssimple MAPI send with attachments inserts spaces
 
I recently ran into a bizarre behavior with Outlook 2003 and 2007 (haven't
tested any others) and the Simple MAPI MAPISendMail function with attachments.

I'm creating a MapiMessage with only attachments in it. As long as there is
more than one attachment, for some reason the send mail dialog that pops up
has 2 spaces in the body for each attachment.

Here's the relevant code. count is the number of attachments:

MapiMessage *const pMsg = new MapiMessage;
ZeroMemory(pMsg, sizeof(MapiMessage));
pMsg-lpFiles = new MapiFileDesc[count];
ZeroMemory(pMsg-lpFiles, sizeof(MapiFileDesc) * count);

for (int i = 0; i count; i++) {
CString filePath(...); // This is where the path to the attachment is
set - details are not relevant to this snippet
pMsg-lpFiles[pMsg-nFileCount].nPosition = -1;
pMsg-lpFiles[pMsg-nFileCount].lpszPathName = new
char[filePath.GetLength() + 1];
strcpy(pMsg-lpFiles[pMsg-nFileCount].lpszPathName, filePath);
pMsg-nFileCount++;
}

if (AfxBeginThread(sendEmailThread, pMsg) == NULL) {
deleteMsg(pMsg);
}

All the sendEmailThread does is call:
MAPISendMail(NULL, NULL, pMsg, MAPI_LOGON_UI | MAPI_DIALOG);

So the only somewhat odd thing going on here are that the MapiMessage is
created in one thread and sent on another. But I tried doing it all in the
same thread and it behaves the same.

As a test I tried setting the body to something other than NULL (I tried
both "" and "test") and in both cases I get the extra spaces plus a new line
before the specified text.

So, either this is a bug in Outlook (neither Outlook Express nor Windows
Mail do it) or I'm missing something. I looked through the flags for the
message itself and the MAPISendMail function and I didn't see anything that
seemed relevant.

The same behavior also occurs when doing a send to mail recipient in Windows
Explorer, which strongly suggests a bug in Outlook.

Any ideas?

Thanks,
Mark Smith



All times are GMT +1. The time now is 02:45 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com