Help!

Ssimple MAPI send with attachments inserts spaces

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Programming VBA RSS
Next:  How do I change font size in Outlook (2002) email..  
Author Message
Mark Smith
External


Since: Jan 28, 2007
Posts: 3



PostPosted: Mon Jun 01, 2009 6:40 am    Post subject: Ssimple MAPI send with attachments inserts spaces
Archived from groups: microsoft>public>outlook>program_vba (more info?)

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
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Programming VBA All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum