Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: How to use CDO to delete copy of messages on POP3 Server?

Geek News

How to use CDO to delete copy of messages on POP3 Server?
Rui Feng 8/24/2006 8:38:01 AM
Hi all.

My Outlook 2003 retrieves emails from a POP3 server. I set to "Leave a copy
of messages on the server" and "Remove from server when deleted from
'Deleted Items'". I wrote a COM Add-in using VC++ 6.0

When recieved a new mail from certain sender, I can catch the
ItemAdd event and use CDO Message->Delete() to permanently delete that
new email. But the email has not been deleted from the POP3 server.

I guess there is a looking-up table in Outlook. When I delete an Email in
"Deleted Items Folder", Outlook find ID of that email and set a value. It
uses that value to notify the POP3 server next time to delete corresponding
email
with the same ID on the server.

I think maybe CDO doesn't tell Outlook that "an email was deleted and please
tell
POP3 Server to delete the copy when connected next time".

Is that true and how to solve it? If you can do it using other programming
language
like VB please tell me anyway.

Thank you. :-)

--------
Beijing, China

Re: How to use CDO to delete copy of messages on POP3 Server?
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 8/24/2006 10:57:49 PM
Outlook stores the list of the message ids in a hidden message
(PR_MESSAGE_CLASS = "IPM.MessageManager") in the Inbox.
However there is no way to tell the POP3 provider in Outlook to delete a
particular message from a POP3 server.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Rui Feng" <Rui Feng[ at ]discussions.microsoft.com> wrote in message
news:59D034E9-5069-4BE4-BEF8-5AF54F56DF41[ at ]microsoft.com...
[Quoted Text]
> Hi all.
>
> My Outlook 2003 retrieves emails from a POP3 server. I set to "Leave a
> copy
> of messages on the server" and "Remove from server when deleted from
> 'Deleted Items'". I wrote a COM Add-in using VC++ 6.0
>
> When recieved a new mail from certain sender, I can catch the
> ItemAdd event and use CDO Message->Delete() to permanently delete that
> new email. But the email has not been deleted from the POP3 server.
>
> I guess there is a looking-up table in Outlook. When I delete an Email in
> "Deleted Items Folder", Outlook find ID of that email and set a value. It
> uses that value to notify the POP3 server next time to delete
> corresponding
> email
> with the same ID on the server.
>
> I think maybe CDO doesn't tell Outlook that "an email was deleted and
> please
> tell
> POP3 Server to delete the copy when connected next time".
>
> Is that true and how to solve it? If you can do it using other programming
> language
> like VB please tell me anyway.
>
> Thank you. :-)
>
> --------
> Beijing, China
>


Re: How to use CDO to delete copy of messages on POP3 Server?
Rui Feng 8/25/2006 9:53:01 AM
So do you think CDO "Message.Delete" method does not delete (maybe forget to
delete) message ids in that hidden message? If this is true, can my add-in
access that hidden message in the Inbox and delete ids?

Thank you.

"Dmitry Streblechenko" wrote:

[Quoted Text]
> Outlook stores the list of the message ids in a hidden message
> (PR_MESSAGE_CLASS = "IPM.MessageManager") in the Inbox.
> However there is no way to tell the POP3 provider in Outlook to delete a
> particular message from a POP3 server.
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "Rui Feng" <Rui Feng[ at ]discussions.microsoft.com> wrote in message
> news:59D034E9-5069-4BE4-BEF8-5AF54F56DF41[ at ]microsoft.com...
> > Hi all.
> >
> > My Outlook 2003 retrieves emails from a POP3 server. I set to "Leave a
> > copy
> > of messages on the server" and "Remove from server when deleted from
> > 'Deleted Items'". I wrote a COM Add-in using VC++ 6.0
> >
> > When recieved a new mail from certain sender, I can catch the
> > ItemAdd event and use CDO Message->Delete() to permanently delete that
> > new email. But the email has not been deleted from the POP3 server.
> >
> > I guess there is a looking-up table in Outlook. When I delete an Email in
> > "Deleted Items Folder", Outlook find ID of that email and set a value. It
> > uses that value to notify the POP3 server next time to delete
> > corresponding
> > email
> > with the same ID on the server.
> >
> > I think maybe CDO doesn't tell Outlook that "an email was deleted and
> > please
> > tell
> > POP3 Server to delete the copy when connected next time".
> >
> > Is that true and how to solve it? If you can do it using other programming
> > language
> > like VB please tell me anyway.
> >
> > Thank you. :-)
> >
> > --------
> > Beijing, China
> >
>
>
>
Re: How to use CDO to delete copy of messages on POP3 Server?
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 8/25/2006 10:04:25 PM
No, it does not delete the message id.
Yes, you can access the list of message ids. If you are using CDO 1.21, use
the Folder.HiddenMessages to find the corresponding message. Look at the
hidden messages with OutlookSpy (click IMAPIFolder, go to the "Associated
Contents" tab) or MFCMAPI.
I don't see however how that will help you - if you delete that message id,
POP3 provider will assume that it is a new message and download it again.
This is the opposite of what you are trying to achieve.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
news:24C2827B-ACE6-4262-A68D-D445BCD08DA1[ at ]microsoft.com...
[Quoted Text]
> So do you think CDO "Message.Delete" method does not delete (maybe forget
> to
> delete) message ids in that hidden message? If this is true, can my add-in
> access that hidden message in the Inbox and delete ids?
>
> Thank you.
>
> "Dmitry Streblechenko" wrote:
>
>> Outlook stores the list of the message ids in a hidden message
>> (PR_MESSAGE_CLASS = "IPM.MessageManager") in the Inbox.
>> However there is no way to tell the POP3 provider in Outlook to delete a
>> particular message from a POP3 server.
>>
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool
>>
>> "Rui Feng" <Rui Feng[ at ]discussions.microsoft.com> wrote in message
>> news:59D034E9-5069-4BE4-BEF8-5AF54F56DF41[ at ]microsoft.com...
>> > Hi all.
>> >
>> > My Outlook 2003 retrieves emails from a POP3 server. I set to "Leave a
>> > copy
>> > of messages on the server" and "Remove from server when deleted from
>> > 'Deleted Items'". I wrote a COM Add-in using VC++ 6.0
>> >
>> > When recieved a new mail from certain sender, I can catch the
>> > ItemAdd event and use CDO Message->Delete() to permanently delete that
>> > new email. But the email has not been deleted from the POP3 server.
>> >
>> > I guess there is a looking-up table in Outlook. When I delete an Email
>> > in
>> > "Deleted Items Folder", Outlook find ID of that email and set a value.
>> > It
>> > uses that value to notify the POP3 server next time to delete
>> > corresponding
>> > email
>> > with the same ID on the server.
>> >
>> > I think maybe CDO doesn't tell Outlook that "an email was deleted and
>> > please
>> > tell
>> > POP3 Server to delete the copy when connected next time".
>> >
>> > Is that true and how to solve it? If you can do it using other
>> > programming
>> > language
>> > like VB please tell me anyway.
>> >
>> > Thank you. :-)
>> >
>> > --------
>> > Beijing, China
>> >
>>
>>
>>


Re: How to use CDO to delete copy of messages on POP3 Server?
Rui Feng 8/27/2006 5:08:01 AM
Thank you MVP. I use your OutlookSpy and it's great!

I find the hidden message and find Outlook stores message ids (UIDL) getting
from POP3 Server in the attachments of that hidden message. The names of
attachments are Blobxxxxxxxx (8 x), Restagsxxxxxxxx (also 8 x),
Deletedxxxxxxxx (also 8 x). There are 3 Blob files, 3 Restags files, and 3
Deleted files, because I have 3 POP3 accounts. Then I have some questions and
need your help.

1. Since I have 3 POP3 accounts, how do I know which Blob, Restags, Deleted
files belong to each of my account?

2. I know the UIDL id stores in Blob file. When I permanently delete a
message, Outlook add its UIDL to Deleted file. I think when logons to POP3
server next time, Outlook will read Deleted file and send DELE command to
POP3 server. If my COM Add-in could add UIDL to Deleted file (in the hidden
message) when permanently deleted a message, Outlook would send DELE command
to POP3 server and delete copy of the message. The first thing I have to do
is get UIDL. I cannot find where UIDL was stored. Is there any relation
between EntryID and UIDL? It's easy to get EntryID.

You are an excellent expert in this area and and I believe you can find a
good way. And I really really really need your help. :-)

Thank you so much!

"Dmitry Streblechenko" wrote:

[Quoted Text]
> No, it does not delete the message id.
> Yes, you can access the list of message ids. If you are using CDO 1.21, use
> the Folder.HiddenMessages to find the corresponding message. Look at the
> hidden messages with OutlookSpy (click IMAPIFolder, go to the "Associated
> Contents" tab) or MFCMAPI.
> I don't see however how that will help you - if you delete that message id,
> POP3 provider will assume that it is a new message and download it again.
> This is the opposite of what you are trying to achieve.
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
> news:24C2827B-ACE6-4262-A68D-D445BCD08DA1[ at ]microsoft.com...
> > So do you think CDO "Message.Delete" method does not delete (maybe forget
> > to
> > delete) message ids in that hidden message? If this is true, can my add-in
> > access that hidden message in the Inbox and delete ids?
> >
> > Thank you.
> >
> > "Dmitry Streblechenko" wrote:
> >
> >> Outlook stores the list of the message ids in a hidden message
> >> (PR_MESSAGE_CLASS = "IPM.MessageManager") in the Inbox.
> >> However there is no way to tell the POP3 provider in Outlook to delete a
> >> particular message from a POP3 server.
> >>
> >> Dmitry Streblechenko (MVP)
> >> http://www.dimastr.com/
> >> OutlookSpy - Outlook, CDO
> >> and MAPI Developer Tool
> >>
> >> "Rui Feng" <Rui Feng[ at ]discussions.microsoft.com> wrote in message
> >> news:59D034E9-5069-4BE4-BEF8-5AF54F56DF41[ at ]microsoft.com...
> >> > Hi all.
> >> >
> >> > My Outlook 2003 retrieves emails from a POP3 server. I set to "Leave a
> >> > copy
> >> > of messages on the server" and "Remove from server when deleted from
> >> > 'Deleted Items'". I wrote a COM Add-in using VC++ 6.0
> >> >
> >> > When recieved a new mail from certain sender, I can catch the
> >> > ItemAdd event and use CDO Message->Delete() to permanently delete that
> >> > new email. But the email has not been deleted from the POP3 server.
> >> >
> >> > I guess there is a looking-up table in Outlook. When I delete an Email
> >> > in
> >> > "Deleted Items Folder", Outlook find ID of that email and set a value.
> >> > It
> >> > uses that value to notify the POP3 server next time to delete
> >> > corresponding
> >> > email
> >> > with the same ID on the server.
> >> >
> >> > I think maybe CDO doesn't tell Outlook that "an email was deleted and
> >> > please
> >> > tell
> >> > POP3 Server to delete the copy when connected next time".
> >> >
> >> > Is that true and how to solve it? If you can do it using other
> >> > programming
> >> > language
> >> > like VB please tell me anyway.
> >> >
> >> > Thank you. :-)
> >> >
> >> > --------
> >> > Beijing, China
> >> >
> >>
> >>
> >>
>
>
>
Re: How to use CDO to delete copy of messages on POP3 Server?
Rui Feng 8/27/2006 11:44:01 AM
Now I find the place where the message stores the UIDL message ids.

Using OutlookSpy, selete a message, then click IMessage button. In "Property
Tag" list of "GetProps" tab, 0x8016 (|ID=0x8f01) is UIDL message ids. The
BINARY value can be parsed to "POP://xxxxxxxx".

I use CDO and OOM and have not used MAPI yet. Do you think using MAPI is the
only way to get this value? Could you give me some example of using MAPI?

I googled and found your another article which said to add these lines:
#define INITGUID
#include <objbase.h>

#define USES_IID_IMessage

#include <mapix.h>
#include <mapitags.h>
#include <mapidefs.h>
#include <mapiutil.h>
#include <mapiguid.h>

These are codes in my program:
CComPtr < IUnknown > spUnknown;
CComPtr < IMessage > spIMessage;
spNewMail->get_MAPIOBJECT(&spUnknown); // point to a message
spUnknown->QueryInterface(IID_IMessage, (void **)&spIMessage);

I get two link errors:
error LNK2001: unresolved external symbol _IID_IMessage
fatal error LNK1120: 1 unresolved externals

Could you tell me how to resolve it? Thank you. :-)


"Dmitry Streblechenko" wrote:

[Quoted Text]
> No, it does not delete the message id.
> Yes, you can access the list of message ids. If you are using CDO 1.21, use
> the Folder.HiddenMessages to find the corresponding message. Look at the
> hidden messages with OutlookSpy (click IMAPIFolder, go to the "Associated
> Contents" tab) or MFCMAPI.
> I don't see however how that will help you - if you delete that message id,
> POP3 provider will assume that it is a new message and download it again.
> This is the opposite of what you are trying to achieve.
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
> news:24C2827B-ACE6-4262-A68D-D445BCD08DA1[ at ]microsoft.com...
> > So do you think CDO "Message.Delete" method does not delete (maybe forget
> > to
> > delete) message ids in that hidden message? If this is true, can my add-in
> > access that hidden message in the Inbox and delete ids?
> >
> > Thank you.
> >
> > "Dmitry Streblechenko" wrote:
> >
> >> Outlook stores the list of the message ids in a hidden message
> >> (PR_MESSAGE_CLASS = "IPM.MessageManager") in the Inbox.
> >> However there is no way to tell the POP3 provider in Outlook to delete a
> >> particular message from a POP3 server.
> >>
> >> Dmitry Streblechenko (MVP)
> >> http://www.dimastr.com/
> >> OutlookSpy - Outlook, CDO
> >> and MAPI Developer Tool
> >>
> >> "Rui Feng" <Rui Feng[ at ]discussions.microsoft.com> wrote in message
> >> news:59D034E9-5069-4BE4-BEF8-5AF54F56DF41[ at ]microsoft.com...
> >> > Hi all.
> >> >
> >> > My Outlook 2003 retrieves emails from a POP3 server. I set to "Leave a
> >> > copy
> >> > of messages on the server" and "Remove from server when deleted from
> >> > 'Deleted Items'". I wrote a COM Add-in using VC++ 6.0
> >> >
> >> > When recieved a new mail from certain sender, I can catch the
> >> > ItemAdd event and use CDO Message->Delete() to permanently delete that
> >> > new email. But the email has not been deleted from the POP3 server.
> >> >
> >> > I guess there is a looking-up table in Outlook. When I delete an Email
> >> > in
> >> > "Deleted Items Folder", Outlook find ID of that email and set a value.
> >> > It
> >> > uses that value to notify the POP3 server next time to delete
> >> > corresponding
> >> > email
> >> > with the same ID on the server.
> >> >
> >> > I think maybe CDO doesn't tell Outlook that "an email was deleted and
> >> > please
> >> > tell
> >> > POP3 Server to delete the copy when connected next time".
> >> >
> >> > Is that true and how to solve it? If you can do it using other
> >> > programming
> >> > language
> >> > like VB please tell me anyway.
> >> >
> >> > Thank you. :-)
> >> >
> >> > --------
> >> > Beijing, China
> >> >
> >>
> >>
> >>
>
>
>
Re: How to use CDO to delete copy of messages on POP3 Server?
Rui Feng 8/28/2006 6:21:02 AM
I've written this and it works:

CComPtr < IUnknown > spUnknown;
CComPtr < IMessage > spIMessage;
spNewMail->get_MAPIOBJECT(&spUnknown);
spUnknown->QueryInterface(IID_IMessage, (void **)&spIMessage);

SPropTagArray Array;
LPSPropTagArray lpArray = &Array;
lpArray->cValues = 1;
lpArray->aulPropTag[0] = 0x80160102;

ULONG FAR lpcValues;
LPSPropValue lppPropArray;
HRESULT hr = spIMessage->GetProps(lpArray, NULL, &lpcValues, &lppPropArray);

int nStrCount = lppPropArray->Value.bin.cb;
_bstr_t bstrPOPString((wchar_t *)lppPropArray->Value.bin.lpb);
char * cPOPString = bstrPOPString;
ATLTRACE("POPSTRING = %s\n", cPOPString);

I do not forget to free them like this:
MAPIFreeBuffer((void *)lpcValues);
MAPIFreeBuffer(lppPropArray);

The UIDL message id have been stored in bstrPOPString. The next step is to
add it to the corresponding attachment of hidden message. I don't know how to
find the exact attachment because I have 3 "Deletedxxxxxxxx" files.

I cannot get its property tag like PR_XXXXXX style because it has no name in
MAPITAGS.H file. Instead, I use 0x80160102 directly. Do you think its
property tag is different in other computers installed Outlook 2003?

Thank you.


"Dmitry Streblechenko" wrote:

[Quoted Text]
> No, it does not delete the message id.
> Yes, you can access the list of message ids. If you are using CDO 1.21, use
> the Folder.HiddenMessages to find the corresponding message. Look at the
> hidden messages with OutlookSpy (click IMAPIFolder, go to the "Associated
> Contents" tab) or MFCMAPI.
> I don't see however how that will help you - if you delete that message id,
> POP3 provider will assume that it is a new message and download it again.
> This is the opposite of what you are trying to achieve.
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
> news:24C2827B-ACE6-4262-A68D-D445BCD08DA1[ at ]microsoft.com...
> > So do you think CDO "Message.Delete" method does not delete (maybe forget
> > to
> > delete) message ids in that hidden message? If this is true, can my add-in
> > access that hidden message in the Inbox and delete ids?
> >
> > Thank you.
> >
> > "Dmitry Streblechenko" wrote:
> >
> >> Outlook stores the list of the message ids in a hidden message
> >> (PR_MESSAGE_CLASS = "IPM.MessageManager") in the Inbox.
> >> However there is no way to tell the POP3 provider in Outlook to delete a
> >> particular message from a POP3 server.
> >>
> >> Dmitry Streblechenko (MVP)
> >> http://www.dimastr.com/
> >> OutlookSpy - Outlook, CDO
> >> and MAPI Developer Tool
> >>
> >> "Rui Feng" <Rui Feng[ at ]discussions.microsoft.com> wrote in message
> >> news:59D034E9-5069-4BE4-BEF8-5AF54F56DF41[ at ]microsoft.com...
> >> > Hi all.
> >> >
> >> > My Outlook 2003 retrieves emails from a POP3 server. I set to "Leave a
> >> > copy
> >> > of messages on the server" and "Remove from server when deleted from
> >> > 'Deleted Items'". I wrote a COM Add-in using VC++ 6.0
> >> >
> >> > When recieved a new mail from certain sender, I can catch the
> >> > ItemAdd event and use CDO Message->Delete() to permanently delete that
> >> > new email. But the email has not been deleted from the POP3 server.
> >> >
> >> > I guess there is a looking-up table in Outlook. When I delete an Email
> >> > in
> >> > "Deleted Items Folder", Outlook find ID of that email and set a value.
> >> > It
> >> > uses that value to notify the POP3 server next time to delete
> >> > corresponding
> >> > email
> >> > with the same ID on the server.
> >> >
> >> > I think maybe CDO doesn't tell Outlook that "an email was deleted and
> >> > please
> >> > tell
> >> > POP3 Server to delete the copy when connected next time".
> >> >
> >> > Is that true and how to solve it? If you can do it using other
> >> > programming
> >> > language
> >> > like VB please tell me anyway.
> >> >
> >> > Thank you. :-)
> >> >
> >> > --------
> >> > Beijing, China
> >> >
> >>
> >>
> >>
>
>
>
Re: How to use CDO to delete copy of messages on POP3 Server?
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 8/28/2006 5:41:55 PM
You cannot hardcode the property tag; it is a named property, you must call
IMessage::GetIDsFromNames first.
I don't know how those messages are mapped to the accounts, sorry. Did you
try to see if anything is available through the IOlkAccountManager (you can
access it through Misc | IOlkAccountManager in OutlookSpy)?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
news:A3E3E9E5-9E08-4326-8F4D-0331DD01344B[ at ]microsoft.com...
[Quoted Text]
> I've written this and it works:
>
> CComPtr < IUnknown > spUnknown;
> CComPtr < IMessage > spIMessage;
> spNewMail->get_MAPIOBJECT(&spUnknown);
> spUnknown->QueryInterface(IID_IMessage, (void **)&spIMessage);
>
> SPropTagArray Array;
> LPSPropTagArray lpArray = &Array;
> lpArray->cValues = 1;
> lpArray->aulPropTag[0] = 0x80160102;
>
> ULONG FAR lpcValues;
> LPSPropValue lppPropArray;
> HRESULT hr = spIMessage->GetProps(lpArray, NULL, &lpcValues,
> &lppPropArray);
>
> int nStrCount = lppPropArray->Value.bin.cb;
> _bstr_t bstrPOPString((wchar_t *)lppPropArray->Value.bin.lpb);
> char * cPOPString = bstrPOPString;
> ATLTRACE("POPSTRING = %s\n", cPOPString);
>
> I do not forget to free them like this:
> MAPIFreeBuffer((void *)lpcValues);
> MAPIFreeBuffer(lppPropArray);
>
> The UIDL message id have been stored in bstrPOPString. The next step is to
> add it to the corresponding attachment of hidden message. I don't know how
> to
> find the exact attachment because I have 3 "Deletedxxxxxxxx" files.
>
> I cannot get its property tag like PR_XXXXXX style because it has no name
> in
> MAPITAGS.H file. Instead, I use 0x80160102 directly. Do you think its
> property tag is different in other computers installed Outlook 2003?
>
> Thank you.
>
>
> "Dmitry Streblechenko" wrote:
>
>> No, it does not delete the message id.
>> Yes, you can access the list of message ids. If you are using CDO 1.21,
>> use
>> the Folder.HiddenMessages to find the corresponding message. Look at the
>> hidden messages with OutlookSpy (click IMAPIFolder, go to the "Associated
>> Contents" tab) or MFCMAPI.
>> I don't see however how that will help you - if you delete that message
>> id,
>> POP3 provider will assume that it is a new message and download it again.
>> This is the opposite of what you are trying to achieve.
>>
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool
>>
>> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
>> news:24C2827B-ACE6-4262-A68D-D445BCD08DA1[ at ]microsoft.com...
>> > So do you think CDO "Message.Delete" method does not delete (maybe
>> > forget
>> > to
>> > delete) message ids in that hidden message? If this is true, can my
>> > add-in
>> > access that hidden message in the Inbox and delete ids?
>> >
>> > Thank you.
>> >
>> > "Dmitry Streblechenko" wrote:
>> >
>> >> Outlook stores the list of the message ids in a hidden message
>> >> (PR_MESSAGE_CLASS = "IPM.MessageManager") in the Inbox.
>> >> However there is no way to tell the POP3 provider in Outlook to delete
>> >> a
>> >> particular message from a POP3 server.
>> >>
>> >> Dmitry Streblechenko (MVP)
>> >> http://www.dimastr.com/
>> >> OutlookSpy - Outlook, CDO
>> >> and MAPI Developer Tool
>> >>
>> >> "Rui Feng" <Rui Feng[ at ]discussions.microsoft.com> wrote in message
>> >> news:59D034E9-5069-4BE4-BEF8-5AF54F56DF41[ at ]microsoft.com...
>> >> > Hi all.
>> >> >
>> >> > My Outlook 2003 retrieves emails from a POP3 server. I set to "Leave
>> >> > a
>> >> > copy
>> >> > of messages on the server" and "Remove from server when deleted from
>> >> > 'Deleted Items'". I wrote a COM Add-in using VC++ 6.0
>> >> >
>> >> > When recieved a new mail from certain sender, I can catch the
>> >> > ItemAdd event and use CDO Message->Delete() to permanently delete
>> >> > that
>> >> > new email. But the email has not been deleted from the POP3 server.
>> >> >
>> >> > I guess there is a looking-up table in Outlook. When I delete an
>> >> > Email
>> >> > in
>> >> > "Deleted Items Folder", Outlook find ID of that email and set a
>> >> > value.
>> >> > It
>> >> > uses that value to notify the POP3 server next time to delete
>> >> > corresponding
>> >> > email
>> >> > with the same ID on the server.
>> >> >
>> >> > I think maybe CDO doesn't tell Outlook that "an email was deleted
>> >> > and
>> >> > please
>> >> > tell
>> >> > POP3 Server to delete the copy when connected next time".
>> >> >
>> >> > Is that true and how to solve it? If you can do it using other
>> >> > programming
>> >> > language
>> >> > like VB please tell me anyway.
>> >> >
>> >> > Thank you. :-)
>> >> >
>> >> > --------
>> >> > Beijing, China
>> >> >
>> >>
>> >>
>> >>
>>
>>
>>


Re: How to use CDO to delete copy of messages on POP3 Server?
Rui Feng 8/29/2006 7:41:02 AM
I have got the whole relations of UIDL message id, attachment file name of
the hidden message, and POP Account ID! And I have got the values in my
program. Thanks for your great OutlookSpy!

Select a message --> IMessage --> GetProps --> Property Tag == 0x8013
The first 8 number of 0x8013 value is POP Account ID. It's HEX and must be
changed to DEC.

In the same window, the value whose Property Tag is equle to "0x8016
(|ID=0x8f01)" is the UIDL message id.

Misc --> IOlkAccountManager
PROP_ACCT_ID is the POP Account ID got from IMessage.

Misc --> IOlkAccountManager --> select an account and click "FindAccount"
The pVar of dwProp whose value is equal to "PT_LONG, 0x0003" is the
attachment file ID of the hidden file. For example, my value is "2192694955".
When changed to HEX, it will be "82b1deab". So the attachment file names of
hidden message in Inbox are "Blob82b1deab", "Restags82b1deab" and
"Deleted82b1deab".

What I have to do now is to add the UIDL message id to the attachment file
whose name is "Deleted82b1deab". Could you tell me how to add something in an
attachment using CDO?

Thank you and have a good day! :-)


"Dmitry Streblechenko" wrote:

[Quoted Text]
> You cannot hardcode the property tag; it is a named property, you must call
> IMessage::GetIDsFromNames first.
> I don't know how those messages are mapped to the accounts, sorry. Did you
> try to see if anything is available through the IOlkAccountManager (you can
> access it through Misc | IOlkAccountManager in OutlookSpy)?
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
> news:A3E3E9E5-9E08-4326-8F4D-0331DD01344B[ at ]microsoft.com...
> > I've written this and it works:
> >
> > CComPtr < IUnknown > spUnknown;
> > CComPtr < IMessage > spIMessage;
> > spNewMail->get_MAPIOBJECT(&spUnknown);
> > spUnknown->QueryInterface(IID_IMessage, (void **)&spIMessage);
> >
> > SPropTagArray Array;
> > LPSPropTagArray lpArray = &Array;
> > lpArray->cValues = 1;
> > lpArray->aulPropTag[0] = 0x80160102;
> >
> > ULONG FAR lpcValues;
> > LPSPropValue lppPropArray;
> > HRESULT hr = spIMessage->GetProps(lpArray, NULL, &lpcValues,
> > &lppPropArray);
> >
> > int nStrCount = lppPropArray->Value.bin.cb;
> > _bstr_t bstrPOPString((wchar_t *)lppPropArray->Value.bin.lpb);
> > char * cPOPString = bstrPOPString;
> > ATLTRACE("POPSTRING = %s\n", cPOPString);
> >
> > I do not forget to free them like this:
> > MAPIFreeBuffer((void *)lpcValues);
> > MAPIFreeBuffer(lppPropArray);
> >
> > The UIDL message id have been stored in bstrPOPString. The next step is to
> > add it to the corresponding attachment of hidden message. I don't know how
> > to
> > find the exact attachment because I have 3 "Deletedxxxxxxxx" files.
> >
> > I cannot get its property tag like PR_XXXXXX style because it has no name
> > in
> > MAPITAGS.H file. Instead, I use 0x80160102 directly. Do you think its
> > property tag is different in other computers installed Outlook 2003?
> >
> > Thank you.
> >
> >
> > "Dmitry Streblechenko" wrote:
> >
> >> No, it does not delete the message id.
> >> Yes, you can access the list of message ids. If you are using CDO 1.21,
> >> use
> >> the Folder.HiddenMessages to find the corresponding message. Look at the
> >> hidden messages with OutlookSpy (click IMAPIFolder, go to the "Associated
> >> Contents" tab) or MFCMAPI.
> >> I don't see however how that will help you - if you delete that message
> >> id,
> >> POP3 provider will assume that it is a new message and download it again.
> >> This is the opposite of what you are trying to achieve.
> >>
> >> Dmitry Streblechenko (MVP)
> >> http://www.dimastr.com/
> >> OutlookSpy - Outlook, CDO
> >> and MAPI Developer Tool
> >>
> >> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
> >> news:24C2827B-ACE6-4262-A68D-D445BCD08DA1[ at ]microsoft.com...
> >> > So do you think CDO "Message.Delete" method does not delete (maybe
> >> > forget
> >> > to
> >> > delete) message ids in that hidden message? If this is true, can my
> >> > add-in
> >> > access that hidden message in the Inbox and delete ids?
> >> >
> >> > Thank you.
> >> >
> >> > "Dmitry Streblechenko" wrote:
> >> >
> >> >> Outlook stores the list of the message ids in a hidden message
> >> >> (PR_MESSAGE_CLASS = "IPM.MessageManager") in the Inbox.
> >> >> However there is no way to tell the POP3 provider in Outlook to delete
> >> >> a
> >> >> particular message from a POP3 server.
> >> >>
> >> >> Dmitry Streblechenko (MVP)
> >> >> http://www.dimastr.com/
> >> >> OutlookSpy - Outlook, CDO
> >> >> and MAPI Developer Tool
> >> >>
> >> >> "Rui Feng" <Rui Feng[ at ]discussions.microsoft.com> wrote in message
> >> >> news:59D034E9-5069-4BE4-BEF8-5AF54F56DF41[ at ]microsoft.com...
> >> >> > Hi all.
> >> >> >
> >> >> > My Outlook 2003 retrieves emails from a POP3 server. I set to "Leave
> >> >> > a
> >> >> > copy
> >> >> > of messages on the server" and "Remove from server when deleted from
> >> >> > 'Deleted Items'". I wrote a COM Add-in using VC++ 6.0
> >> >> >
> >> >> > When recieved a new mail from certain sender, I can catch the
> >> >> > ItemAdd event and use CDO Message->Delete() to permanently delete
> >> >> > that
> >> >> > new email. But the email has not been deleted from the POP3 server.
> >> >> >
> >> >> > I guess there is a looking-up table in Outlook. When I delete an
> >> >> > Email
> >> >> > in
> >> >> > "Deleted Items Folder", Outlook find ID of that email and set a
> >> >> > value.
> >> >> > It
> >> >> > uses that value to notify the POP3 server next time to delete
> >> >> > corresponding
> >> >> > email
> >> >> > with the same ID on the server.
> >> >> >
> >> >> > I think maybe CDO doesn't tell Outlook that "an email was deleted
> >> >> > and
> >> >> > please
> >> >> > tell
> >> >> > POP3 Server to delete the copy when connected next time".
> >> >> >
> >> >> > Is that true and how to solve it? If you can do it using other
> >> >> > programming
> >> >> > language
> >> >> > like VB please tell me anyway.
> >> >> >
> >> >> > Thank you. :-)
> >> >> >
> >> >> > --------
> >> >> > Beijing, China
> >> >> >
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Re: How to use CDO to delete copy of messages on POP3 Server?
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 8/29/2006 6:07:22 PM
CDO does nott allow to modify the attachment data directly, so you wowuld
need to save the attachment as a file, modify it, delete the old attachment,
add the new one.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
news:A7CEE1C2-D70A-4E4D-89CA-61D40887B79D[ at ]microsoft.com...
[Quoted Text]
>I have got the whole relations of UIDL message id, attachment file name of
> the hidden message, and POP Account ID! And I have got the values in my
> program. Thanks for your great OutlookSpy!
>
> Select a message --> IMessage --> GetProps --> Property Tag == 0x8013
> The first 8 number of 0x8013 value is POP Account ID. It's HEX and must be
> changed to DEC.
>
> In the same window, the value whose Property Tag is equle to "0x8016
> (|ID=0x8f01)" is the UIDL message id.
>
> Misc --> IOlkAccountManager
> PROP_ACCT_ID is the POP Account ID got from IMessage.
>
> Misc --> IOlkAccountManager --> select an account and click "FindAccount"
> The pVar of dwProp whose value is equal to "PT_LONG, 0x0003" is the
> attachment file ID of the hidden file. For example, my value is
> "2192694955".
> When changed to HEX, it will be "82b1deab". So the attachment file names
> of
> hidden message in Inbox are "Blob82b1deab", "Restags82b1deab" and
> "Deleted82b1deab".
>
> What I have to do now is to add the UIDL message id to the attachment file
> whose name is "Deleted82b1deab". Could you tell me how to add something in
> an
> attachment using CDO?
>
> Thank you and have a good day! :-)
>
>
> "Dmitry Streblechenko" wrote:
>
>> You cannot hardcode the property tag; it is a named property, you must
>> call
>> IMessage::GetIDsFromNames first.
>> I don't know how those messages are mapped to the accounts, sorry. Did
>> you
>> try to see if anything is available through the IOlkAccountManager (you
>> can
>> access it through Misc | IOlkAccountManager in OutlookSpy)?
>>
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool
>>
>> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
>> news:A3E3E9E5-9E08-4326-8F4D-0331DD01344B[ at ]microsoft.com...
>> > I've written this and it works:
>> >
>> > CComPtr < IUnknown > spUnknown;
>> > CComPtr < IMessage > spIMessage;
>> > spNewMail->get_MAPIOBJECT(&spUnknown);
>> > spUnknown->QueryInterface(IID_IMessage, (void **)&spIMessage);
>> >
>> > SPropTagArray Array;
>> > LPSPropTagArray lpArray = &Array;
>> > lpArray->cValues = 1;
>> > lpArray->aulPropTag[0] = 0x80160102;
>> >
>> > ULONG FAR lpcValues;
>> > LPSPropValue lppPropArray;
>> > HRESULT hr = spIMessage->GetProps(lpArray, NULL, &lpcValues,
>> > &lppPropArray);
>> >
>> > int nStrCount = lppPropArray->Value.bin.cb;
>> > _bstr_t bstrPOPString((wchar_t *)lppPropArray->Value.bin.lpb);
>> > char * cPOPString = bstrPOPString;
>> > ATLTRACE("POPSTRING = %s\n", cPOPString);
>> >
>> > I do not forget to free them like this:
>> > MAPIFreeBuffer((void *)lpcValues);
>> > MAPIFreeBuffer(lppPropArray);
>> >
>> > The UIDL message id have been stored in bstrPOPString. The next step is
>> > to
>> > add it to the corresponding attachment of hidden message. I don't know
>> > how
>> > to
>> > find the exact attachment because I have 3 "Deletedxxxxxxxx" files.
>> >
>> > I cannot get its property tag like PR_XXXXXX style because it has no
>> > name
>> > in
>> > MAPITAGS.H file. Instead, I use 0x80160102 directly. Do you think its
>> > property tag is different in other computers installed Outlook 2003?
>> >
>> > Thank you.
>> >
>> >
>> > "Dmitry Streblechenko" wrote:
>> >
>> >> No, it does not delete the message id.
>> >> Yes, you can access the list of message ids. If you are using CDO
>> >> 1.21,
>> >> use
>> >> the Folder.HiddenMessages to find the corresponding message. Look at
>> >> the
>> >> hidden messages with OutlookSpy (click IMAPIFolder, go to the
>> >> "Associated
>> >> Contents" tab) or MFCMAPI.
>> >> I don't see however how that will help you - if you delete that
>> >> message
>> >> id,
>> >> POP3 provider will assume that it is a new message and download it
>> >> again.
>> >> This is the opposite of what you are trying to achieve.
>> >>
>> >> Dmitry Streblechenko (MVP)
>> >> http://www.dimastr.com/
>> >> OutlookSpy - Outlook, CDO
>> >> and MAPI Developer Tool
>> >>
>> >> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
>> >> news:24C2827B-ACE6-4262-A68D-D445BCD08DA1[ at ]microsoft.com...
>> >> > So do you think CDO "Message.Delete" method does not delete (maybe
>> >> > forget
>> >> > to
>> >> > delete) message ids in that hidden message? If this is true, can my
>> >> > add-in
>> >> > access that hidden message in the Inbox and delete ids?
>> >> >
>> >> > Thank you.
>> >> >
>> >> > "Dmitry Streblechenko" wrote:
>> >> >
>> >> >> Outlook stores the list of the message ids in a hidden message
>> >> >> (PR_MESSAGE_CLASS = "IPM.MessageManager") in the Inbox.
>> >> >> However there is no way to tell the POP3 provider in Outlook to
>> >> >> delete
>> >> >> a
>> >> >> particular message from a POP3 server.
>> >> >>
>> >> >> Dmitry Streblechenko (MVP)
>> >> >> http://www.dimastr.com/
>> >> >> OutlookSpy - Outlook, CDO
>> >> >> and MAPI Developer Tool
>> >> >>
>> >> >> "Rui Feng" <Rui Feng[ at ]discussions.microsoft.com> wrote in message
>> >> >> news:59D034E9-5069-4BE4-BEF8-5AF54F56DF41[ at ]microsoft.com...
>> >> >> > Hi all.
>> >> >> >
>> >> >> > My Outlook 2003 retrieves emails from a POP3 server. I set to
>> >> >> > "Leave
>> >> >> > a
>> >> >> > copy
>> >> >> > of messages on the server" and "Remove from server when deleted
>> >> >> > from
>> >> >> > 'Deleted Items'". I wrote a COM Add-in using VC++ 6.0
>> >> >> >
>> >> >> > When recieved a new mail from certain sender, I can catch the
>> >> >> > ItemAdd event and use CDO Message->Delete() to permanently delete
>> >> >> > that
>> >> >> > new email. But the email has not been deleted from the POP3
>> >> >> > server.
>> >> >> >
>> >> >> > I guess there is a looking-up table in Outlook. When I delete an
>> >> >> > Email
>> >> >> > in
>> >> >> > "Deleted Items Folder", Outlook find ID of that email and set a
>> >> >> > value.
>> >> >> > It
>> >> >> > uses that value to notify the POP3 server next time to delete
>> >> >> > corresponding
>> >> >> > email
>> >> >> > with the same ID on the server.
>> >> >> >
>> >> >> > I think maybe CDO doesn't tell Outlook that "an email was deleted
>> >> >> > and
>> >> >> > please
>> >> >> > tell
>> >> >> > POP3 Server to delete the copy when connected next time".
>> >> >> >
>> >> >> > Is that true and how to solve it? If you can do it using other
>> >> >> > programming
>> >> >> > language
>> >> >> > like VB please tell me anyway.
>> >> >> >
>> >> >> > Thank you. :-)
>> >> >> >
>> >> >> > --------
>> >> >> > Beijing, China
>> >> >> >
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>


Re: How to use CDO to delete copy of messages on POP3 Server?
Rui Feng 8/31/2006 2:15:02 PM
Dear MVP,

When I delete an email using CDO delete() method, I use
Attachment::WriteToFile, Attachment::ReadFromFile, and Message::Update() to
modify the "Deletedxxxxxxxx" attachment of the hidden message successfully.
But when I synchronize my POP3 account with POP3 server, the copy of message
is not deleted in POP3 server.

I guess there is a flag to tell Outlook whether read "Deletedxxxxxxxx"
attachment. If I delete a message in Inbox and then delete it permanently in
the "Deleted Item Box", Outlook stores the UID in the "Deletedxxxxxxxx"
attachment of hidden message, and sets the flag. When synchronizing with POP3
Server, Outlook reads the flag and knows that some messages have been
permanently deleted. So Outlook starts to read "Deletedxxxxxxxx" attachment
and gets the UID.

But when my add-in adds UID to that attachment, it does not set the flag, so
Outlook does not know if anything has changed and does not read that
attachment.

I have searched the whole values using OutlookSpy but could not find the
flag. Could you tell me what happened when synchronizing with POP3 Server,
which flag or value should I modify, and how to tell Outlook to read the
"Deletedxxxxxxxx" attachment of hidden message in Inbox when synchronizing
with POP3 Server? This is the last step to achieve the goal. :-)

Thank you so much!

----------
Rui Feng
Beijing, China


"Dmitry Streblechenko" wrote:

[Quoted Text]
> CDO does nott allow to modify the attachment data directly, so you wowuld
> need to save the attachment as a file, modify it, delete the old attachment,
> add the new one.
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
> news:A7CEE1C2-D70A-4E4D-89CA-61D40887B79D[ at ]microsoft.com...
> >I have got the whole relations of UIDL message id, attachment file name of
> > the hidden message, and POP Account ID! And I have got the values in my
> > program. Thanks for your great OutlookSpy!
> >
> > Select a message --> IMessage --> GetProps --> Property Tag == 0x8013
> > The first 8 number of 0x8013 value is POP Account ID. It's HEX and must be
> > changed to DEC.
> >
> > In the same window, the value whose Property Tag is equle to "0x8016
> > (|ID=0x8f01)" is the UIDL message id.
> >
> > Misc --> IOlkAccountManager
> > PROP_ACCT_ID is the POP Account ID got from IMessage.
> >
> > Misc --> IOlkAccountManager --> select an account and click "FindAccount"
> > The pVar of dwProp whose value is equal to "PT_LONG, 0x0003" is the
> > attachment file ID of the hidden file. For example, my value is
> > "2192694955".
> > When changed to HEX, it will be "82b1deab". So the attachment file names
> > of
> > hidden message in Inbox are "Blob82b1deab", "Restags82b1deab" and
> > "Deleted82b1deab".
> >
> > What I have to do now is to add the UIDL message id to the attachment file
> > whose name is "Deleted82b1deab". Could you tell me how to add something in
> > an
> > attachment using CDO?
> >
> > Thank you and have a good day! :-)
> >
> >
> > "Dmitry Streblechenko" wrote:
> >
> >> You cannot hardcode the property tag; it is a named property, you must
> >> call
> >> IMessage::GetIDsFromNames first.
> >> I don't know how those messages are mapped to the accounts, sorry. Did
> >> you
> >> try to see if anything is available through the IOlkAccountManager (you
> >> can
> >> access it through Misc | IOlkAccountManager in OutlookSpy)?
> >>
> >> Dmitry Streblechenko (MVP)
> >> http://www.dimastr.com/
> >> OutlookSpy - Outlook, CDO
> >> and MAPI Developer Tool
> >>
> >> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
> >> news:A3E3E9E5-9E08-4326-8F4D-0331DD01344B[ at ]microsoft.com...
> >> > I've written this and it works:
> >> >
> >> > CComPtr < IUnknown > spUnknown;
> >> > CComPtr < IMessage > spIMessage;
> >> > spNewMail->get_MAPIOBJECT(&spUnknown);
> >> > spUnknown->QueryInterface(IID_IMessage, (void **)&spIMessage);
> >> >
> >> > SPropTagArray Array;
> >> > LPSPropTagArray lpArray = &Array;
> >> > lpArray->cValues = 1;
> >> > lpArray->aulPropTag[0] = 0x80160102;
> >> >
> >> > ULONG FAR lpcValues;
> >> > LPSPropValue lppPropArray;
> >> > HRESULT hr = spIMessage->GetProps(lpArray, NULL, &lpcValues,
> >> > &lppPropArray);
> >> >
> >> > int nStrCount = lppPropArray->Value.bin.cb;
> >> > _bstr_t bstrPOPString((wchar_t *)lppPropArray->Value.bin.lpb);
> >> > char * cPOPString = bstrPOPString;
> >> > ATLTRACE("POPSTRING = %s\n", cPOPString);
> >> >
> >> > I do not forget to free them like this:
> >> > MAPIFreeBuffer((void *)lpcValues);
> >> > MAPIFreeBuffer(lppPropArray);
> >> >
> >> > The UIDL message id have been stored in bstrPOPString. The next step is
> >> > to
> >> > add it to the corresponding attachment of hidden message. I don't know
> >> > how
> >> > to
> >> > find the exact attachment because I have 3 "Deletedxxxxxxxx" files.
> >> >
> >> > I cannot get its property tag like PR_XXXXXX style because it has no
> >> > name
> >> > in
> >> > MAPITAGS.H file. Instead, I use 0x80160102 directly. Do you think its
> >> > property tag is different in other computers installed Outlook 2003?
> >> >
> >> > Thank you.
> >> >
> >> >
> >> > "Dmitry Streblechenko" wrote:
> >> >
> >> >> No, it does not delete the message id.
> >> >> Yes, you can access the list of message ids. If you are using CDO
> >> >> 1.21,
> >> >> use
> >> >> the Folder.HiddenMessages to find the corresponding message. Look at
> >> >> the
> >> >> hidden messages with OutlookSpy (click IMAPIFolder, go to the
> >> >> "Associated
> >> >> Contents" tab) or MFCMAPI.
> >> >> I don't see however how that will help you - if you delete that
> >> >> message
> >> >> id,
> >> >> POP3 provider will assume that it is a new message and download it
> >> >> again.
> >> >> This is the opposite of what you are trying to achieve.
> >> >>
> >> >> Dmitry Streblechenko (MVP)
> >> >> http://www.dimastr.com/
> >> >> OutlookSpy - Outlook, CDO
> >> >> and MAPI Developer Tool
> >> >>
> >> >> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
> >> >> news:24C2827B-ACE6-4262-A68D-D445BCD08DA1[ at ]microsoft.com...
> >> >> > So do you think CDO "Message.Delete" method does not delete (maybe
> >> >> > forget
> >> >> > to
> >> >> > delete) message ids in that hidden message? If this is true, can my
> >> >> > add-in
> >> >> > access that hidden message in the Inbox and delete ids?
> >> >> >
> >> >> > Thank you.
> >> >> >
> >> >> > "Dmitry Streblechenko" wrote:
> >> >> >
> >> >> >> Outlook stores the list of the message ids in a hidden message
> >> >> >> (PR_MESSAGE_CLASS = "IPM.MessageManager") in the Inbox.
> >> >> >> However there is no way to tell the POP3 provider in Outlook to
> >> >> >> delete
> >> >> >> a
> >> >> >> particular message from a POP3 server.
> >> >> >>
> >> >> >> Dmitry Streblechenko (MVP)
> >> >> >> http://www.dimastr.com/
> >> >> >> OutlookSpy - Outlook, CDO
> >> >> >> and MAPI Developer Tool
> >> >> >>
> >> >> >> "Rui Feng" <Rui Feng[ at ]discussions.microsoft.com> wrote in message
> >> >> >> news:59D034E9-5069-4BE4-BEF8-5AF54F56DF41[ at ]microsoft.com...
> >> >> >> > Hi all.
> >> >> >> >
> >> >> >> > My Outlook 2003 retrieves emails from a POP3 server. I set to
> >> >> >> > "Leave
> >> >> >> > a
> >> >> >> > copy
> >> >> >> > of messages on the server" and "Remove from server when deleted
> >> >> >> > from
> >> >> >> > 'Deleted Items'". I wrote a COM Add-in using VC++ 6.0
> >> >> >> >
> >> >> >> > When recieved a new mail from certain sender, I can catch the
> >> >> >> > ItemAdd event and use CDO Message->Delete() to permanently delete
> >> >> >> > that
> >> >> >> > new email. But the email has not been deleted from the POP3
> >> >> >> > server.
> >> >> >> >
> >> >> >> > I guess there is a looking-up table in Outlook. When I delete an
> >> >> >> > Email
> >> >> >> > in
> >> >> >> > "Deleted Items Folder", Outlook find ID of that email and set a
> >> >> >> > value.
> >> >> >> > It
> >> >> >> > uses that value to notify the POP3 server next time to delete
> >> >> >> > corresponding
> >> >> >> > email
> >> >> >> > with the same ID on the server.
> >> >> >> >
> >> >> >> > I think maybe CDO doesn't tell Outlook that "an email was deleted
> >> >> >> > and
> >> >> >> > please
> >> >> >> > tell
> >> >> >> > POP3 Server to delete the copy when connected next time".
> >> >> >> >
> >> >> >> > Is that true and how to solve it? If you can do it using other
> >> >> >> > programming
> >> >> >> > language
> >> >> >> > like VB please tell me anyway.
> >> >> >> >
> >> >> >> > Thank you. :-)
> >> >> >> >
> >> >> >> > --------
> >> >> >> > Beijing, China
> >> >> >> >
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Re: How to use CDO to delete copy of messages on POP3 Server?
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 8/31/2006 5:03:49 PM
I have no idea, sorry.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
news:259BCCE3-3776-46ED-9963-C19B717AC62D[ at ]microsoft.com...
[Quoted Text]
> Dear MVP,
>
> When I delete an email using CDO delete() method, I use
> Attachment::WriteToFile, Attachment::ReadFromFile, and Message::Update()
> to
> modify the "Deletedxxxxxxxx" attachment of the hidden message
> successfully.
> But when I synchronize my POP3 account with POP3 server, the copy of
> message
> is not deleted in POP3 server.
>
> I guess there is a flag to tell Outlook whether read "Deletedxxxxxxxx"
> attachment. If I delete a message in Inbox and then delete it permanently
> in
> the "Deleted Item Box", Outlook stores the UID in the "Deletedxxxxxxxx"
> attachment of hidden message, and sets the flag. When synchronizing with
> POP3
> Server, Outlook reads the flag and knows that some messages have been
> permanently deleted. So Outlook starts to read "Deletedxxxxxxxx"
> attachment
> and gets the UID.
>
> But when my add-in adds UID to that attachment, it does not set the flag,
> so
> Outlook does not know if anything has changed and does not read that
> attachment.
>
> I have searched the whole values using OutlookSpy but could not find the
> flag. Could you tell me what happened when synchronizing with POP3 Server,
> which flag or value should I modify, and how to tell Outlook to read the
> "Deletedxxxxxxxx" attachment of hidden message in Inbox when synchronizing
> with POP3 Server? This is the last step to achieve the goal. :-)
>
> Thank you so much!
>
> ----------
> Rui Feng
> Beijing, China
>
>
> "Dmitry Streblechenko" wrote:
>
>> CDO does nott allow to modify the attachment data directly, so you wowuld
>> need to save the attachment as a file, modify it, delete the old
>> attachment,
>> add the new one.
>>
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool
>>
>> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
>> news:A7CEE1C2-D70A-4E4D-89CA-61D40887B79D[ at ]microsoft.com...
>> >I have got the whole relations of UIDL message id, attachment file name
>> >of
>> > the hidden message, and POP Account ID! And I have got the values in my
>> > program. Thanks for your great OutlookSpy!
>> >
>> > Select a message --> IMessage --> GetProps --> Property Tag == 0x8013
>> > The first 8 number of 0x8013 value is POP Account ID. It's HEX and must
>> > be
>> > changed to DEC.
>> >
>> > In the same window, the value whose Property Tag is equle to "0x8016
>> > (|ID=0x8f01)" is the UIDL message id.
>> >
>> > Misc --> IOlkAccountManager
>> > PROP_ACCT_ID is the POP Account ID got from IMessage.
>> >
>> > Misc --> IOlkAccountManager --> select an account and click
>> > "FindAccount"
>> > The pVar of dwProp whose value is equal to "PT_LONG, 0x0003" is the
>> > attachment file ID of the hidden file. For example, my value is
>> > "2192694955".
>> > When changed to HEX, it will be "82b1deab". So the attachment file
>> > names
>> > of
>> > hidden message in Inbox are "Blob82b1deab", "Restags82b1deab" and
>> > "Deleted82b1deab".
>> >
>> > What I have to do now is to add the UIDL message id to the attachment
>> > file
>> > whose name is "Deleted82b1deab". Could you tell me how to add something
>> > in
>> > an
>> > attachment using CDO?
>> >
>> > Thank you and have a good day! :-)
>> >
>> >
>> > "Dmitry Streblechenko" wrote:
>> >
>> >> You cannot hardcode the property tag; it is a named property, you must
>> >> call
>> >> IMessage::GetIDsFromNames first.
>> >> I don't know how those messages are mapped to the accounts, sorry. Did
>> >> you
>> >> try to see if anything is available through the IOlkAccountManager
>> >> (you
>> >> can
>> >> access it through Misc | IOlkAccountManager in OutlookSpy)?
>> >>
>> >> Dmitry Streblechenko (MVP)
>> >> http://www.dimastr.com/
>> >> OutlookSpy - Outlook, CDO
>> >> and MAPI Developer Tool
>> >>
>> >> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
>> >> news:A3E3E9E5-9E08-4326-8F4D-0331DD01344B[ at ]microsoft.com...
>> >> > I've written this and it works:
>> >> >
>> >> > CComPtr < IUnknown > spUnknown;
>> >> > CComPtr < IMessage > spIMessage;
>> >> > spNewMail->get_MAPIOBJECT(&spUnknown);
>> >> > spUnknown->QueryInterface(IID_IMessage, (void **)&spIMessage);
>> >> >
>> >> > SPropTagArray Array;
>> >> > LPSPropTagArray lpArray = &Array;
>> >> > lpArray->cValues = 1;
>> >> > lpArray->aulPropTag[0] = 0x80160102;
>> >> >
>> >> > ULONG FAR lpcValues;
>> >> > LPSPropValue lppPropArray;
>> >> > HRESULT hr = spIMessage->GetProps(lpArray, NULL, &lpcValues,
>> >> > &lppPropArray);
>> >> >
>> >> > int nStrCount = lppPropArray->Value.bin.cb;
>> >> > _bstr_t bstrPOPString((wchar_t *)lppPropArray->Value.bin.lpb);
>> >> > char * cPOPString = bstrPOPString;
>> >> > ATLTRACE("POPSTRING = %s\n", cPOPString);
>> >> >
>> >> > I do not forget to free them like this:
>> >> > MAPIFreeBuffer((void *)lpcValues);
>> >> > MAPIFreeBuffer(lppPropArray);
>> >> >
>> >> > The UIDL message id have been stored in bstrPOPString. The next step
>> >> > is
>> >> > to
>> >> > add it to the corresponding attachment of hidden message. I don't
>> >> > know
>> >> > how
>> >> > to
>> >> > find the exact attachment because I have 3 "Deletedxxxxxxxx" files.
>> >> >
>> >> > I cannot get its property tag like PR_XXXXXX style because it has no
>> >> > name
>> >> > in
>> >> > MAPITAGS.H file. Instead, I use 0x80160102 directly. Do you think
>> >> > its
>> >> > property tag is different in other computers installed Outlook 2003?
>> >> >
>> >> > Thank you.
>> >> >
>> >> >
>> >> > "Dmitry Streblechenko" wrote:
>> >> >
>> >> >> No, it does not delete the message id.
>> >> >> Yes, you can access the list of message ids. If you are using CDO
>> >> >> 1.21,
>> >> >> use
>> >> >> the Folder.HiddenMessages to find the corresponding message. Look
>> >> >> at
>> >> >> the
>> >> >> hidden messages with OutlookSpy (click IMAPIFolder, go to the
>> >> >> "Associated
>> >> >> Contents" tab) or MFCMAPI.
>> >> >> I don't see however how that will help you - if you delete that
>> >> >> message
>> >> >> id,
>> >> >> POP3 provider will assume that it is a new message and download it
>> >> >> again.
>> >> >> This is the opposite of what you are trying to achieve.
>> >> >>
>> >> >> Dmitry Streblechenko (MVP)
>> >> >> http://www.dimastr.com/
>> >> >> OutlookSpy - Outlook, CDO
>> >> >> and MAPI Developer Tool
>> >> >>
>> >> >> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
>> >> >> news:24C2827B-ACE6-4262-A68D-D445BCD08DA1[ at ]microsoft.com...
>> >> >> > So do you think CDO "Message.Delete" method does not delete
>> >> >> > (maybe
>> >> >> > forget
>> >> >> > to
>> >> >> > delete) message ids in that hidden message? If this is true, can
>> >> >> > my
>> >> >> > add-in
>> >> >> > access that hidden message in the Inbox and delete ids?
>> >> >> >
>> >> >> > Thank you.
>> >> >> >
>> >> >> > "Dmitry Streblechenko" wrote:
>> >> >> >
>> >> >> >> Outlook stores the list of the message ids in a hidden message
>> >> >> >> (PR_MESSAGE_CLASS = "IPM.MessageManager") in the Inbox.
>> >> >> >> However there is no way to tell the POP3 provider in Outlook to
>> >> >> >> delete
>> >> >> >> a
>> >> >> >> particular message from a POP3 server.
>> >> >> >>
>> >> >> >> Dmitry Streblechenko (MVP)
>> >> >> >> http://www.dimastr.com/
>> >> >> >> OutlookSpy - Outlook, CDO
>> >> >> >> and MAPI Developer Tool
>> >> >> >>
>> >> >> >> "Rui Feng" <Rui Feng[ at ]discussions.microsoft.com> wrote in message
>> >> >> >> news:59D034E9-5069-4BE4-BEF8-5AF54F56DF41[ at ]microsoft.com...
>> >> >> >> > Hi all.
>> >> >> >> >
>> >> >> >> > My Outlook 2003 retrieves emails from a POP3 server. I set to
>> >> >> >> > "Leave
>> >> >> >> > a
>> >> >> >> > copy
>> >> >> >> > of messages on the server" and "Remove from server when
>> >> >> >> > deleted
>> >> >> >> > from
>> >> >> >> > 'Deleted Items'". I wrote a COM Add-in using VC++ 6.0
>> >> >> >> >
>> >> >> >> > When recieved a new mail from certain sender, I can catch the
>> >> >> >> > ItemAdd event and use CDO Message->Delete() to permanently
>> >> >> >> > delete
>> >> >> >> > that
>> >> >> >> > new email. But the email has not been deleted from the POP3
>> >> >> >> > server.
>> >> >> >> >
>> >> >> >> > I guess there is a looking-up table in Outlook. When I delete
>> >> >> >> > an
>> >> >> >> > Email
>> >> >> >> > in
>> >> >> >> > "Deleted Items Folder", Outlook find ID of that email and set
>> >> >> >> > a
>> >> >> >> > value.
>> >> >> >> > It
>> >> >> >> > uses that value to notify the POP3 server next time to delete
>> >> >> >> > corresponding
>> >> >> >> > email
>> >> >> >> > with the same ID on the server.
>> >> >> >> >
>> >> >> >> > I think maybe CDO doesn't tell Outlook that "an email was
>> >> >> >> > deleted
>> >> >> >> > and
>> >> >> >> > please
>> >> >> >> > tell
>> >> >> >> > POP3 Server to delete the copy when connected next time".
>> >> >> >> >
>> >> >> >> > Is that true and how to solve it? If you can do it using other
>> >> >> >> > programming
>> >> >> >> > language
>> >> >> >> > like VB please tell me anyway.
>> >> >> >> >
>> >> >> >> > Thank you. :-)
>> >> >> >> >
>> >> >> >> > --------
>> >> >> >> > Beijing, China
>> >> >> >> >
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>


Re: How to use CDO to delete copy of messages on POP3 Server?
Rui Feng 9/1/2006 4:06:02 AM
Dear MVP,

Could you please help me to check this function in the source code of
Outlook? It's quite important for me to delete the copy of POP3 server.

Thank you!

Rui Feng


"Dmitry Streblechenko" wrote:

[Quoted Text]
> I have no idea, sorry.
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
> news:259BCCE3-3776-46ED-9963-C19B717AC62D[ at ]microsoft.com...
> > Dear MVP,
> >
> > When I delete an email using CDO delete() method, I use
> > Attachment::WriteToFile, Attachment::ReadFromFile, and Message::Update()
> > to
> > modify the "Deletedxxxxxxxx" attachment of the hidden message
> > successfully.
> > But when I synchronize my POP3 account with POP3 server, the copy of
> > message
> > is not deleted in POP3 server.
> >
> > I guess there is a flag to tell Outlook whether read "Deletedxxxxxxxx"
> > attachment. If I delete a message in Inbox and then delete it permanently
> > in
> > the "Deleted Item Box", Outlook stores the UID in the "Deletedxxxxxxxx"
> > attachment of hidden message, and sets the flag. When synchronizing with
> > POP3
> > Server, Outlook reads the flag and knows that some messages have been
> > permanently deleted. So Outlook starts to read "Deletedxxxxxxxx"
> > attachment
> > and gets the UID.
> >
> > But when my add-in adds UID to that attachment, it does not set the flag,
> > so
> > Outlook does not know if anything has changed and does not read that
> > attachment.
> >
> > I have searched the whole values using OutlookSpy but could not find the
> > flag. Could you tell me what happened when synchronizing with POP3 Server,
> > which flag or value should I modify, and how to tell Outlook to read the
> > "Deletedxxxxxxxx" attachment of hidden message in Inbox when synchronizing
> > with POP3 Server? This is the last step to achieve the goal. :-)
> >
> > Thank you so much!
> >
> > ----------
> > Rui Feng
> > Beijing, China
> >
> >
> > "Dmitry Streblechenko" wrote:
> >
> >> CDO does nott allow to modify the attachment data directly, so you wowuld
> >> need to save the attachment as a file, modify it, delete the old
> >> attachment,
> >> add the new one.
> >>
> >> Dmitry Streblechenko (MVP)
> >> http://www.dimastr.com/
> >> OutlookSpy - Outlook, CDO
> >> and MAPI Developer Tool
> >>
> >> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
> >> news:A7CEE1C2-D70A-4E4D-89CA-61D40887B79D[ at ]microsoft.com...
> >> >I have got the whole relations of UIDL message id, attachment file name
> >> >of
> >> > the hidden message, and POP Account ID! And I have got the values in my
> >> > program. Thanks for your great OutlookSpy!
> >> >
> >> > Select a message --> IMessage --> GetProps --> Property Tag == 0x8013
> >> > The first 8 number of 0x8013 value is POP Account ID. It's HEX and must
> >> > be
> >> > changed to DEC.
> >> >
> >> > In the same window, the value whose Property Tag is equle to "0x8016
> >> > (|ID=0x8f01)" is the UIDL message id.
> >> >
> >> > Misc --> IOlkAccountManager
> >> > PROP_ACCT_ID is the POP Account ID got from IMessage.
> >> >
> >> > Misc --> IOlkAccountManager --> select an account and click
> >> > "FindAccount"
> >> > The pVar of dwProp whose value is equal to "PT_LONG, 0x0003" is the
> >> > attachment file ID of the hidden file. For example, my value is
> >> > "2192694955".
> >> > When changed to HEX, it will be "82b1deab". So the attachment file
> >> > names
> >> > of
> >> > hidden message in Inbox are "Blob82b1deab", "Restags82b1deab" and
> >> > "Deleted82b1deab".
> >> >
> >> > What I have to do now is to add the UIDL message id to the attachment
> >> > file
> >> > whose name is "Deleted82b1deab". Could you tell me how to add something
> >> > in
> >> > an
> >> > attachment using CDO?
> >> >
> >> > Thank you and have a good day! :-)
> >> >
> >> >
> >> > "Dmitry Streblechenko" wrote:
> >> >
> >> >> You cannot hardcode the property tag; it is a named property, you must
> >> >> call
> >> >> IMessage::GetIDsFromNames first.
> >> >> I don't know how those messages are mapped to the accounts, sorry. Did
> >> >> you
> >> >> try to see if anything is available through the IOlkAccountManager
> >> >> (you
> >> >> can
> >> >> access it through Misc | IOlkAccountManager in OutlookSpy)?
> >> >>
> >> >> Dmitry Streblechenko (MVP)
> >> >> http://www.dimastr.com/
> >> >> OutlookSpy - Outlook, CDO
> >> >> and MAPI Developer Tool
> >> >>
> >> >> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
> >> >> news:A3E3E9E5-9E08-4326-8F4D-0331DD01344B[ at ]microsoft.com...
> >> >> > I've written this and it works:
> >> >> >
> >> >> > CComPtr < IUnknown > spUnknown;
> >> >> > CComPtr < IMessage > spIMessage;
> >> >> > spNewMail->get_MAPIOBJECT(&spUnknown);
> >> >> > spUnknown->QueryInterface(IID_IMessage, (void **)&spIMessage);
> >> >> >
> >> >> > SPropTagArray Array;
> >> >> > LPSPropTagArray lpArray = &Array;
> >> >> > lpArray->cValues = 1;
> >> >> > lpArray->aulPropTag[0] = 0x80160102;
> >> >> >
> >> >> > ULONG FAR lpcValues;
> >> >> > LPSPropValue lppPropArray;
> >> >> > HRESULT hr = spIMessage->GetProps(lpArray, NULL, &lpcValues,
> >> >> > &lppPropArray);
> >> >> >
> >> >> > int nStrCount = lppPropArray->Value.bin.cb;
> >> >> > _bstr_t bstrPOPString((wchar_t *)lppPropArray->Value.bin.lpb);
> >> >> > char * cPOPString = bstrPOPString;
> >> >> > ATLTRACE("POPSTRING = %s\n", cPOPString);
> >> >> >
> >> >> > I do not forget to free them like this:
> >> >> > MAPIFreeBuffer((void *)lpcValues);
> >> >> > MAPIFreeBuffer(lppPropArray);
> >> >> >
> >> >> > The UIDL message id have been stored in bstrPOPString. The next step
> >> >> > is
> >> >> > to
> >> >> > add it to the corresponding attachment of hidden message. I don't
> >> >> > know
> >> >> > how
> >> >> > to
> >> >> > find the exact attachment because I have 3 "Deletedxxxxxxxx" files.
> >> >> >
> >> >> > I cannot get its property tag like PR_XXXXXX style because it has no
> >> >> > name
> >> >> > in
> >> >> > MAPITAGS.H file. Instead, I use 0x80160102 directly. Do you think
> >> >> > its
> >> >> > property tag is different in other computers installed Outlook 2003?
> >> >> >
> >> >> > Thank you.
> >> >> >
> >> >> >
> >> >> > "Dmitry Streblechenko" wrote:
> >> >> >
> >> >> >> No, it does not delete the message id.
> >> >> >> Yes, you can access the list of message ids. If you are using CDO
> >> >> >> 1.21,
> >> >> >> use
> >> >> >> the Folder.HiddenMessages to find the corresponding message. Look
> >> >> >> at
> >> >> >> the
> >> >> >> hidden messages with OutlookSpy (click IMAPIFolder, go to the
> >> >> >> "Associated
> >> >> >> Contents" tab) or MFCMAPI.
> >> >> >> I don't see however how that will help you - if you delete that
> >> >> >> message
> >> >> >> id,
> >> >> >> POP3 provider will assume that it is a new message and download it
> >> >> >> again.
> >> >> >> This is the opposite of what you are trying to achieve.
> >> >> >>
> >> >> >> Dmitry Streblechenko (MVP)
> >> >> >> http://www.dimastr.com/
> >> >> >> OutlookSpy - Outlook, CDO
> >> >> >> and MAPI Developer Tool
> >> >> >>
> >> >> >> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
> >> >> >> news:24C2827B-ACE6-4262-A68D-D445BCD08DA1[ at ]microsoft.com...
> >> >> >> > So do you think CDO "Message.Delete" method does not delete
> >> >> >> > (maybe
> >> >> >> > forget
> >> >> >> > to
> >> >> >> > delete) message ids in that hidden message? If this is true, can
> >> >> >> > my
> >> >> >> > add-in
> >> >> >> > access that hidden message in the Inbox and delete ids?
> >> >> >> >
> >> >> >> > Thank you.
> >> >> >> >
> >> >> >> > "Dmitry Streblechenko" wrote:
> >> >> >> >
> >> >> >> >> Outlook stores the list of the message ids in a hidden message
> >> >> >> >> (PR_MESSAGE_CLASS = "IPM.MessageManager") in the Inbox.
> >> >> >> >> However there is no way to tell the POP3 provider in Outlook to
> >> >> >> >> delete
> >> >> >> >> a
> >> >> >> >> particular message from a POP3 server.
> >> >> >> >>
> >> >> >> >> Dmitry Streblechenko (MVP)
> >> >> >> >> http://www.dimastr.com/
> >> >> >> >> OutlookSpy - Outlook, CDO
> >> >> >> >> and MAPI Developer Tool
> >> >> >> >>
> >> >> >> >> "Rui Feng" <Rui Feng[ at ]discussions.microsoft.com> wrote in message
> >> >> >> >> news:59D034E9-5069-4BE4-BEF8-5AF54F56DF41[ at ]microsoft.com...
> >> >> >> >> > Hi all.
> >> >> >> >> >
> >> >> >> >> > My Outlook 2003 retrieves emails from a POP3 server. I set to
> >> >> >> >> > "Leave
> >> >> >> >> > a
> >> >> >> >> > copy
> >> >> >> >> > of messages on the server" and "Remove from server when
> >> >> >> >> > deleted
> >> >> >> >> > from
> >> >> >> >> > 'Deleted Items'". I wrote a COM Add-in using VC++ 6.0
> >> >> >> >> >
> >> >> >> >> > When recieved a new mail from certain sender, I can catch the
> >> >> >> >> > ItemAdd event and use CDO Message->Delete() to permanently
> >> >> >> >> > delete
> >> >> >> >> > that
> >> >> >> >> > new email. But the email has not been deleted from the POP3
> >> >> >> >> > server.
> >> >> >> >> >
> >> >> >> >> > I guess there is a looking-up table in Outlook. When I delete
> >> >> >> >> > an
> >> >> >> >> > Email
> >> >> >> >> > in
> >> >> >> >> > "Deleted Items Folder", Outlook find ID of that email and set
> >> >> >> >> > a
> >> >> >> >> > value.
> >> >> >> >> > It
> >> >> >> >> > uses that value to notify the POP3 server next time to delete
> >> >> >> >> > corresponding
> >> >> >> >> > email
> >> >> >> >> > with the same ID on the server.
> >> >> >> >> >
> >> >> >> >> > I think maybe CDO doesn't tell Outlook that "an email was
> >> >> >> >> > deleted
> >> >> >> >> > and
> >> >> >> >> > please
> >> >> >> >> > tell
> >> >> >> >> > POP3 Server to delete the copy when connected next time".
> >> >> >> >> >
> >> >> >> >> > Is that true and how to solve it? If you can do it using other
> >> >> >> >> > programming
> >> >> >> >> > language
> >> >> >> >> > like VB please tell me anyway.
> >> >> >> >> >
> >> >> >> >> > Thank you. :-)
> >> >> >> >> >
> >> >> >> >> > --------
> >> >> >> >> > Beijing, China
> >> >> >> >> >
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Re: How to use CDO to delete copy of messages on POP3 Server?
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 9/1/2006 9:38:17 PM
I wish I had access to the Outlook source code. Unfortunately I don't...
Just to clear any possible misconceptions, MVPs are non-paid volunteers, we
are not employed or paid by MS.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
news:D8914AEB-8DF3-45DB-B1FC-03C9D28C8AB6[ at ]microsoft.com...
[Quoted Text]
> Dear MVP,
>
> Could you please help me to check this function in the source code of
> Outlook? It's quite important for me to delete the copy of POP3 server.
>
> Thank you!
>
> Rui Feng
>
>
> "Dmitry Streblechenko" wrote:
>
>> I have no idea, sorry.
>>
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool
>>
>> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
>> news:259BCCE3-3776-46ED-9963-C19B717AC62D[ at ]microsoft.com...
>> > Dear MVP,
>> >
>> > When I delete an email using CDO delete() method, I use
>> > Attachment::WriteToFile, Attachment::ReadFromFile, and
>> > Message::Update()
>> > to
>> > modify the "Deletedxxxxxxxx" attachment of the hidden message
>> > successfully.
>> > But when I synchronize my POP3 account with POP3 server, the copy of
>> > message
>> > is not deleted in POP3 server.
>> >
>> > I guess there is a flag to tell Outlook whether read "Deletedxxxxxxxx"
>> > attachment. If I delete a message in Inbox and then delete it
>> > permanently
>> > in
>> > the "Deleted Item Box", Outlook stores the UID in the "Deletedxxxxxxxx"
>> > attachment of hidden message, and sets the flag. When synchronizing
>> > with
>> > POP3
>> > Server, Outlook reads the flag and knows that some messages have been
>> > permanently deleted. So Outlook starts to read "Deletedxxxxxxxx"
>> > attachment
>> > and gets the UID.
>> >
>> > But when my add-in adds UID to that attachment, it does not set the
>> > flag,
>> > so
>> > Outlook does not know if anything has changed and does not read that
>> > attachment.
>> >
>> > I have searched the whole values using OutlookSpy but could not find
>> > the
>> > flag. Could you tell me what happened when synchronizing with POP3
>> > Server,
>> > which flag or value should I modify, and how to tell Outlook to read
>> > the
>> > "Deletedxxxxxxxx" attachment of hidden message in Inbox when
>> > synchronizing
>> > with POP3 Server? This is the last step to achieve the goal. :-)
>> >
>> > Thank you so much!
>> >
>> > ----------
>> > Rui Feng
>> > Beijing, China
>> >
>> >
>> > "Dmitry Streblechenko" wrote:
>> >
>> >> CDO does nott allow to modify the attachment data directly, so you
>> >> wowuld
>> >> need to save the attachment as a file, modify it, delete the old
>> >> attachment,
>> >> add the new one.
>> >>
>> >> Dmitry Streblechenko (MVP)
>> >> http://www.dimastr.com/
>> >> OutlookSpy - Outlook, CDO
>> >> and MAPI Developer Tool
>> >>
>> >> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
>> >> news:A7CEE1C2-D70A-4E4D-89CA-61D40887B79D[ at ]microsoft.com...
>> >> >I have got the whole relations of UIDL message id, attachment file
>> >> >name
>> >> >of
>> >> > the hidden message, and POP Account ID! And I have got the values in
>> >> > my
>> >> > program. Thanks for your great OutlookSpy!
>> >> >
>> >> > Select a message --> IMessage --> GetProps --> Property Tag ==
>> >> > 0x8013
>> >> > The first 8 number of 0x8013 value is POP Account ID. It's HEX and
>> >> > must
>> >> > be
>> >> > changed to DEC.
>> >> >
>> >> > In the same window, the value whose Property Tag is equle to "0x8016
>> >> > (|ID=0x8f01)" is the UIDL message id.
>> >> >
>> >> > Misc --> IOlkAccountManager
>> >> > PROP_ACCT_ID is the POP Account ID got from IMessage.
>> >> >
>> >> > Misc --> IOlkAccountManager --> select an account and click
>> >> > "FindAccount"
>> >> > The pVar of dwProp whose value is equal to "PT_LONG, 0x0003" is the
>> >> > attachment file ID of the hidden file. For example, my value is
>> >> > "2192694955".
>> >> > When changed to HEX, it will be "82b1deab". So the attachment file
>> >> > names
>> >> > of
>> >> > hidden message in Inbox are "Blob82b1deab", "Restags82b1deab" and
>> >> > "Deleted82b1deab".
>> >> >
>> >> > What I have to do now is to add the UIDL message id to the
>> >> > attachment
>> >> > file
>> >> > whose name is "Deleted82b1deab". Could you tell me how to add
>> >> > something
>> >> > in
>> >> > an
>> >> > attachment using CDO?
>> >> >
>> >> > Thank you and have a good day! :-)
>> >> >
>> >> >
>> >> > "Dmitry Streblechenko" wrote:
>> >> >
>> >> >> You cannot hardcode the property tag; it is a named property, you
>> >> >> must
>> >> >> call
>> >> >> IMessage::GetIDsFromNames first.
>> >> >> I don't know how those messages are mapped to the accounts, sorry.
>> >> >> Did
>> >> >> you
>> >> >> try to see if anything is available through the IOlkAccountManager
>> >> >> (you
>> >> >> can
>> >> >> access it through Misc | IOlkAccountManager in OutlookSpy)?
>> >> >>
>> >> >> Dmitry Streblechenko (MVP)
>> >> >> http://www.dimastr.com/
>> >> >> OutlookSpy - Outlook, CDO
>> >> >> and MAPI Developer Tool
>> >> >>
>> >> >> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
>> >> >> news:A3E3E9E5-9E08-4326-8F4D-0331DD01344B[ at ]microsoft.com...
>> >> >> > I've written this and it works:
>> >> >> >
>> >> >> > CComPtr < IUnknown > spUnknown;
>> >> >> > CComPtr < IMessage > spIMessage;
>> >> >> > spNewMail->get_MAPIOBJECT(&spUnknown);
>> >> >> > spUnknown->QueryInterface(IID_IMessage, (void **)&spIMessage);
>> >> >> >
>> >> >> > SPropTagArray Array;
>> >> >> > LPSPropTagArray lpArray = &Array;
>> >> >> > lpArray->cValues = 1;
>> >> >> > lpArray->aulPropTag[0] = 0x80160102;
>> >> >> >
>> >> >> > ULONG FAR lpcValues;
>> >> >> > LPSPropValue lppPropArray;
>> >> >> > HRESULT hr = spIMessage->GetProps(lpArray, NULL, &lpcValues,
>> >> >> > &lppPropArray);
>> >> >> >
>> >> >> > int nStrCount = lppPropArray->Value.bin.cb;
>> >> >> > _bstr_t bstrPOPString((wchar_t *)lppPropArray->Value.bin.lpb);
>> >> >> > char * cPOPString = bstrPOPString;
>> >> >> > ATLTRACE("POPSTRING = %s\n", cPOPString);
>> >> >> >
>> >> >> > I do not forget to free them like this:
>> >> >> > MAPIFreeBuffer((void *)lpcValues);
>> >> >> > MAPIFreeBuffer(lppPropArray);
>> >> >> >
>> >> >> > The UIDL message id have been stored in bstrPOPString. The next
>> >> >> > step
>> >> >> > is
>> >> >> > to
>> >> >> > add it to the corresponding attachment of hidden message. I don't
>> >> >> > know
>> >> >> > how
>> >> >> > to
>> >> >> > find the exact attachment because I have 3 "Deletedxxxxxxxx"
>> >> >> > files.
>> >> >> >
>> >> >> > I cannot get its property tag like PR_XXXXXX style because it has
>> >> >> > no
>> >> >> > name
>> >> >> > in
>> >> >> > MAPITAGS.H file. Instead, I use 0x80160102 directly. Do you think
>> >> >> > its
>> >> >> > property tag is different in other computers installed Outlook
>> >> >> > 2003?
>> >> >> >
>> >> >> > Thank you.
>> >> >> >
>> >> >> >
>> >> >> > "Dmitry Streblechenko" wrote:
>> >> >> >
>> >> >> >> No, it does not delete the message id.
>> >> >> >> Yes, you can access the list of message ids. If you are using
>> >> >> >> CDO
>> >> >> >> 1.21,
>> >> >> >> use
>> >> >> >> the Folder.HiddenMessages to find the corresponding message.
>> >> >> >> Look
>> >> >> >> at
>> >> >> >> the
>> >> >> >> hidden messages with OutlookSpy (click IMAPIFolder, go to the
>> >> >> >> "Associated
>> >> >> >> Contents" tab) or MFCMAPI.
>> >> >> >> I don't see however how that will help you - if you delete that
>> >> >> >> message
>> >> >> >> id,
>> >> >> >> POP3 provider will assume that it is a new message and download
>> >> >> >> it
>> >> >> >> again.
>> >> >> >> This is the opposite of what you are trying to achieve.
>> >> >> >>
>> >> >> >> Dmitry Streblechenko (MVP)
>> >> >> >> http://www.dimastr.com/
>> >> >> >> OutlookSpy - Outlook, CDO
>> >> >> >> and MAPI Developer Tool
>> >> >> >>
>> >> >> >> "Rui Feng" <RuiFeng[ at ]discussions.microsoft.com> wrote in message
>> >> >> >> news:24C2827B-ACE6-4262-A68D-D445BCD08DA1[ at ]microsoft.com...
>> >> >> >> > So do you think CDO "Message.Delete" method does not delete
>> >> >> >> > (maybe
>> >> >> >> > forget
>> >> >> >> > to
>> >> >> >> > delete) message ids in that hidden message? If this is true,
>> >> >> >> > can
>> >> >> >> > my
>> >> >> >> > add-in
>> >> >> >> > access that hidden message in the Inbox and delete ids?
>> >> >> >> >
>> >> >> >> > Thank you.
>> >> >> >> >
>> >> >> >> > "Dmitry Streblechenko" wrote:
>> >> >> >> >
>> >> >> >> >> Outlook stores the list of the message ids in a hidden
>> >> >> >> >> message
>> >> >> >> >> (PR_MESSAGE_CLASS = "IPM.MessageManager") in the Inbox.
>> >> >> >> >> However there is no way to tell the POP3 provider in Outlook
>> >> >> >> >> to
>> >> >> >> >> delete
>> >> >> >> >> a
>> >> >> >> >> particular message from a POP3 server.
>> >> >> >> >>
>> >> >> >> >> Dmitry Streblechenko (MVP)
>> >> >> >> >> http://www.dimastr.com/
>> >> >> >> >> OutlookSpy - Outlook, CDO
>> >> >> >> >> and MAPI Developer Tool
>> >> >> >> >>
>> >> >> >> >> "Rui Feng" <Rui Feng[ at ]discussions.microsoft.com> wrote in
>> >> >> >> >> message
>> >> >> >> >> news:59D034E9-5069-4BE4-BEF8-5AF54F56DF41[ at ]microsoft.com...
>> >> >> >> >> > Hi all.
>> >> >> >> >> >
>> >> >> >> >> > My Outlook 2003 retrieves emails from a POP3 server. I set
>> >> >> >> >> > to
>> >> >> >> >> > "Leave
>> >> >> >> >> > a
>> >> >> >> >> > copy
>> >> >> >> >> > of messages on the server" and "Remove from server when
>> >> >> >> >> > deleted
>> >> >> >> >> > from
>> >> >> >> >> > 'Deleted Items'". I wrote a COM Add-in using VC++ 6.0
>> >> >> >> >> >
>> >> >> >> >> > When recieved a new mail from certain sender, I can catch
>> >> >> >> >> > the
>> >> >> >> >> > ItemAdd event and use CDO Message->Delete() to permanently
>> >> >> >> >> > delete
>> >> >> >> >> > that
>> >> >> >> >> > new email. But the email has not been deleted from the POP3
>> >> >> >> >> > server.
>> >> >> >> >> >
>> >> >> >> >> > I guess there is a looking-up table in Outlook. When I
>> >> >> >> >> > delete
>> >> >> >> >> > an
>> >> >> >> >> > Email
>> >> >> >> >> > in
>> >> >> >> >> > "Deleted Items Folder", Outlook find ID of that email and
>> >> >> >> >> > set
>> >> >> >> >> > a
>> >> >> >> >> > value.
>> >> >> >> >> > It
>> >> >> >> >> > uses that value to notify the POP3 server next time to
>> >> >> >> >> > delete
>> >> >> >> >> > corresponding
>> >> >> >> >> > email
>> >> >> >> >> > with the same ID on the server.
>> >> >> >> >> >
>> >> >> >> >> > I think maybe CDO doesn't tell Outlook that "an email was
>> >> >> >> >> > deleted
>> >> >> >> >> > and
>> >> >> >> >> > please
>> >> >> >> >> > tell
>> >> >> >> >> > POP3 Server to delete the copy when connected next time".
>> >> >> >> >> >
>> >> >> >> >> > Is that true and how to solve it? If you can do it using
>> >> >> >> >> > other
>> >> >> >> >> > programming
>> >> >> >> >> > language
>> >> >> >> >> > like VB please tell me anyway.
>> >> >> >> >> >
>> >> >> >> >> > Thank you. :-)
>> >> >> >> >> >
>> >> >> >> >> > --------
>> >> >> >> >> > Beijing, China
>> >> >> >> >> >
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net