problem using Parent property of MailItem

K

kf9150

hello, what i'm trying to do is moving the MailItem just sent to
appropriate folder if needed. but before that, i need to check from
which folder the mail was sent. using following code, the returned
parent folder name is always "inbox" no matter which folder the mail
was sent from. any suggestion? thanks for help. - kelie

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)
Dim objMail As MailItem

If TypeOf Item Is MailItem Then
Set objMail = Item
Debug.Print objMail.Parent.Name
End If
End Sub
 
D

Dmitry Streblechenko

What exactly do you mean by "from which folder the mail was sent"? When you
create a new message, Outlook creates it in the Inbox (but does not save
it). Once you save it, it goes to the Drafts folder.
Do you mean you need to find which folder was displayed in the Explorer when
the message was sent? Application.ActiveExplorer.CurrentFolder will give
you that.

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

kf9150

What exactly do you mean by "from which folder the mail was sent"? When you
create a new message, Outlook creates it in the Inbox (but does not save
it). Once you save it, it goes to the Drafts folder.
Do you mean you need to find which folder was displayed in the Explorer when
the message was sent? Application.ActiveExplorer.CurrentFolder will give
you that.

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

Dmitry, thanks for your reply. i have many folders created for
different projects i'm working on. in each folder there are emails for
a paticular project. when i reply emails from such folder, the parent
folder should be that folder, instead of "inbox", is it correct?
thanks.
 
D

Dmitry Streblechenko

No, the parent folder will be the Inbox, Drafts or Sent Items.
There is no hard link between the message being replied to and the reply.

1. You can watch the selection change event in all Explorer objects and set
up event sinks on all selected items. You will then receive the
MailItem.Reply event
whenever the user hits Reply button. That will be the original message and
MailItem.Parent on that message will give you the fodler.
2. Retrieve the value of the ConversationIndex property, delete the last 5
bytes (10 chars since OOM returns it as a hex string), then try to find a
message with that conversation index, hoping that the selected folder is
where the old message lives. Or search all teh relevant folders.
3. You can assume that whenever Inspectors.NewInspector even fires,
Application.ActiveExplorer.Selection or
Application.ActiveInspector.CurrentItem will give you the original item(s).


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

kf9150

No, the parent folder will be the Inbox, Drafts or Sent Items.
There is no hard link between the message being replied to and the reply.

Thanks again Dmitry. i'll try your suggested methods, probably the
first one and the third one, and see if i can work something out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top