A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Ssimple MAPI send with attachments inserts spaces



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 1st 09, 02:40 PM posted to microsoft.public.outlook.program_vba
Mark Smith[_2_]
external usenet poster
 
Posts: 3
Default 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

Ads
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple MAPI send and Outlook COM addin Mark Smith[_2_] Outlook and VBA 3 June 16th 09 03:29 PM
Is there a way to use mapi to send faxes out through outlook? StratfordWard Outlook - Fax Functions 2 September 11th 08 03:16 AM
Send email with MAPI doesn't save mails in sent items Giorgio Vanoni Add-ins for Outlook 3 June 5th 08 05:55 PM
Send mail using MAPI and not get a prompt Sanjay_S Outlook and VBA 1 November 8th 06 02:46 PM
Accessing attachments in Outlook using MAPI [email protected] Add-ins for Outlook 1 February 9th 06 08:09 PM


All times are GMT +1. The time now is 02:41 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.