PC Review


Reply
Thread Tools Rate Thread

Attachment added via MAPI not visible in preview pane

 
 
New Member
Join Date: Apr 2009
Posts: 4
 
      4th Aug 2009
Hi,
I'm making an addIn for outlook which is adding the attachments to the incoming message. I had problems using MailItem.Attachments.Add method so I have used MAPI Ex method to add attachments. I have a problem that attachments larger then 100K are not visible in the message window when the message is stored in folder. There is indicator in explorer window that message contains attachments, and they can be seen and opened(right click on the message, View->Attachments). The code that I'm using is shown bellow. After the outlook is restarted the attachments are visible.Any ideas what I might be doing wrong?

Thanks

Vladimir

__declspec(dllexport) HRESULT AddAttachment(LPMESSAGE message, LPSTR pszFileName, int pathLen, char* src, int size)
{

LPATTACH pAttach = NULL;
ULONG ulAttNum;
HRESULT hRes;

SPropValue *oneProp = NULL;

enum {METHOD,ATTACH_FILENAME,ATTACH_LONG_FILENAME,ATTACH_PATHNAME,ATTACHMENT_FLAGS,ATTACH_SIZE,NUM_ATT_PROPS};

SPropValue props[NUM_ATT_PROPS];

SPropProblemArray* probs=NULL;
LPSTREAM pStrmDest = NULL;
ULONG bytesWritten = 0;



// Create an attachment on the message
if (FAILED(hRes = message->CreateAttach(NULL, (ULONG)0, &ulAttNum, &pAttach)))
{

goto Quit;
}

props[METHOD].ulPropTag =PR_ATTACH_METHOD;

props[METHOD].Value.l =ATTACH_BY_VALUE;


//set standard file properties
props[ATTACH_PATHNAME].ulPropTag =PR_ATTACH_PATHNAME;

props[ATTACH_PATHNAME].Value.lpszA =pszFileName;

props[ATTACH_FILENAME].ulPropTag =PR_ATTACH_FILENAME;

props[ATTACH_FILENAME].Value.lpszA = pszFileName;
props[ATTACH_LONG_FILENAME].ulPropTag =PR_ATTACH_LONG_FILENAME;

props[ATTACH_LONG_FILENAME].Value.lpszA =pszFileName;


props[ATTACH_PATHNAME].ulPropTag =PR_ATTACH_PATHNAME;

props[ATTACH_PATHNAME].Value.lpszA =pszFileName;

props[ATTACHMENT_FLAGS].ulPropTag = PR_ATTACHMENT_FLAGS;
props[ATTACHMENT_FLAGS].Value.l = 0;

props[ATTACH_SIZE].ulPropTag = PR_ATTACH_SIZE;
props[ATTACH_SIZE].Value.l = size;

if(FAILED(hRes=pAttach->SetProps(NUM_ATT_PROPS, props, &probs)))
{

goto Quit;
}

//pAttach -> SaveChanges(0);

if (FAILED(hRes = pAttach->OpenProperty(
PR_ATTACH_DATA_BIN,
(LPIID)&IID_IStream,
STGM_WRITE,
MAPI_CREATE|MAPI_MODIFY ,
(LPUNKNOWN *)&pStrmDest)))
{

goto Quit;
}


pStrmDest->Write(src,size,&bytesWritten);


pStrmDest->Commit(0);

// Save the changes to the Attachment
pAttach -> SaveChanges(0);

message->SaveChanges(KEEP_OPEN_READWRITE);

// message->Release();*/

Quit:
if(pStrmDest)
pStrmDest -> Release();
if (pAttach)
pAttach -> Release();

return hRes;
}
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Image is not visible in print preview when watermark is added. Noel Microsoft Word Document Management 2 13th Aug 2009 04:16 PM
text visible in preview is not in the reading pane =?Utf-8?B?UiBIZWxmcmljaA==?= Microsoft Outlook Discussion 2 12th Oct 2005 08:50 AM
No text visible in emails, but part text visible in preview pane? =?Utf-8?B?S2FwaXRlaW4gUm9i?= Microsoft Outlook Discussion 1 4th Jul 2005 09:35 AM
Message visible in Preview Pane but NOT in email! =?Utf-8?B?RWxpb3Q=?= Microsoft Outlook 9 15th Nov 2004 03:33 PM
Outlook 2003 Attachments Visible in Preview pane Doc Don Sturgiss Microsoft Outlook Installation 1 26th Jul 2003 06:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:41 PM.