Outlook插件使用ATL / COM [英] Outlook addin using ATL/COM

查看:321
本文介绍了Outlook插件使用ATL / COM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







我试图在c ++中使用ATL / COM开发outlook插件。我想获取MailItem方法来访问outlook邮件,这样我就可以获得所需的结果,如TO,CC,BCC,Subject,Body和附件......直到现在我已经得到了所有接受附件,这里是我的代码获取附件





Hi,


I m trying to develop outlook plugin using ATL/COM in c++. I want to get the MailItem methods to access the outlook mail so that i can get the desired results like TO, CC, BCC, Subject, Body and attachments.....till now i have got everything accept attachments here is my code for getting attachments


CComPtr<Outlook::_MailItem> MailPtr;
CComQIPtr<Outlook::Attachments> spAttachments;
CComQIPtr<Outlook::Attachment> spAttachment;



长计数;




long count;

MailPtr->get_Attachments (&spAttachments);

spAttachments->get_Count (&count);







for (;count--; )
{
    VARIANT index;
    index.iVal = 1; // value
    index.vt = VT_I2; // type of variant = integer
    BSTR StoragePtr;

    spAttachments->Item (index, &spAttachment);

    spAttachment->get_FileName (&StoragePtr);
    MessageBoxW (NULL, (LPCWSTR)StoragePtr, L"Attached File Name", MB_OK);



}



以上代码仅适用于一个附件,但如果有多个附件当它在第二次出现在这条线上时,它正在崩溃它正在崩溃





spAttachments-> ;项目(索引,& spAttachment);



im无法获取第二个附件的文件名,所以请任何人帮我解决这个问题。



提前谢谢。


}

The above code works fine for only one attachment but if there are more than one attachments it is getting crash when it comes for the second time in the for loop here at this line it is getting crash


spAttachments->Item (index, &spAttachment);

i m not able to get the file name of the second attachment so please anyone help me to this problem.

Thanks in advance.

推荐答案

我想知道你是如何解决这个问题的?我最近遇到了它。

这是一个错误吗?
I wonder how you solve the problem? I met it recently.
Is it a bug?


哦,我找到了解决问题的方法!!

只需删除:CComQIPtr< outlook :: attachment xmlns:outlook =#unknown> spAttachment;

进入for循环。



我认为方法Item在发现它不是NULL时拒绝覆盖spAttachment
Oh, I've found a way to figure it out!!
Just Remove : CComQIPtr<outlook::attachment xmlns:outlook="#unknown"> spAttachment;
into for loop.

I think method "Item" refuse to overwrite spAttachment when he found it's not NULL


这篇关于Outlook插件使用ATL / COM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆