How do I know whether a mail is replied/forwarded ?

G

Guest

Iam using C#.net for outlook programming.
I want to know whether a mail is replied/forwarded or not in my Inbox.
Are there any properties like replied/Isreplied/forwarded/Isforwarded
for a MailItem ??
 
K

Ken Slovak - [MVP - Outlook]

The Outlook object model doesn't let you find that. You would need to use a
different API such as CDO 1.21 or Extended MAPI or Redemption
(www.dimastr.com/redemption). Neither CDO or Extended MAPI can be used from
..NET languages.

The property you would read would be PR_LAST_VERB_EXECUTED (0x10810003).

EXCHIVERB_REPLYTOSENDER = 102
EXCHIVERB_REPLYTOALL = 103
EXCHIVERB_FORWARD = 104
 
G

Guest

Thanks for your reply.

As per your reply, I tried to implement the same in VBA(not using C#.Net).
But, I got an error which is mentioned below.
"cdoPR_LAST_VERB_EXECUTED" is giving error.

Run-time error '-2147221233(8004010f)':
Collaboration Data Objects
[Collaboration Data Objects - [MAPI_E_NOT_FOUND(8004010F)]]

'Code I have implemented
Dim cdoInbox As MAPI.Folder
Dim cdoSession As MAPI.Session
Dim objmsg As MAPI.Message
Dim cdoField As MAPI.Field


Set cdoSession = CreateObject("MAPI.Session")
cdoSession.Logon "outlook", "", False, False
'cdoSession.Logon newSession:=False
Set cdoInbox = cdoSession.Inbox

For Each objmsg In cdoInbox.Messages
Set cdoField = objmsg.Fields(cdoPR_LAST_VERB_EXECUTED) 'error statement
MsgBox (cdoField.Value)
Next

Do you have any idea as to what could be the reason ?

Thanks
Bhanu
 
K

Ken Slovak - [MVP - Outlook]

That field isn't a default field. In other words it's not always there. If
an item in Inbox hasn't had any action taken on it that field won't be
there. After you send a reply, reply all or forward is when the field is
added.

With any code in CDO or RDO or MAPI you need to handle those cases. Where
the field doesn't exist clear the error and go on to the next item.

On Error Resume Next

For Each objmsg In cdoInbox.Messages
Set cdoField = objmsg.Fields(cdoPR_LAST_VERB_EXECUTED) 'error statement
If Err.Number <> 0 Then
Err.Clear
Else
MsgBox (cdoField.Value)
End If
Next




Bhanu said:
Thanks for your reply.

As per your reply, I tried to implement the same in VBA(not using C#.Net).
But, I got an error which is mentioned below.
"cdoPR_LAST_VERB_EXECUTED" is giving error.

Run-time error '-2147221233(8004010f)':
Collaboration Data Objects
[Collaboration Data Objects - [MAPI_E_NOT_FOUND(8004010F)]]

'Code I have implemented
Dim cdoInbox As MAPI.Folder
Dim cdoSession As MAPI.Session
Dim objmsg As MAPI.Message
Dim cdoField As MAPI.Field


Set cdoSession = CreateObject("MAPI.Session")
cdoSession.Logon "outlook", "", False, False
'cdoSession.Logon newSession:=False
Set cdoInbox = cdoSession.Inbox

For Each objmsg In cdoInbox.Messages
Set cdoField = objmsg.Fields(cdoPR_LAST_VERB_EXECUTED) 'error
statement
MsgBox (cdoField.Value)
Next

Do you have any idea as to what could be the reason ?

Thanks
Bhanu



Ken Slovak - said:
The Outlook object model doesn't let you find that. You would need to use
a
different API such as CDO 1.21 or Extended MAPI or Redemption
(www.dimastr.com/redemption). Neither CDO or Extended MAPI can be used
from
..NET languages.

The property you would read would be PR_LAST_VERB_EXECUTED (0x10810003).

EXCHIVERB_REPLYTOSENDER = 102
EXCHIVERB_REPLYTOALL = 103
EXCHIVERB_FORWARD = 104
 
G

Guest

Great, That's working. Thanks alot.
But I started getting one exception while reading "Undeliverable Mails(by
System Administrator) which are in my mailbox. The exception is "Specified
Cast is Invalid".
The code I have written is below :

for(int j=1; j<=folder.Items.Count; j++)
{
subjectItem = (Outlook.MailItemClass)(folder.Items[j]); //error
statement
}

but it is giving an exception mentioned above, while reading "Undeliverable
Mails".


More help is needed on how to handle such mails........


Thanks
Bhanu

Ken Slovak - said:
That field isn't a default field. In other words it's not always there. If
an item in Inbox hasn't had any action taken on it that field won't be
there. After you send a reply, reply all or forward is when the field is
added.

With any code in CDO or RDO or MAPI you need to handle those cases. Where
the field doesn't exist clear the error and go on to the next item.

On Error Resume Next

For Each objmsg In cdoInbox.Messages
Set cdoField = objmsg.Fields(cdoPR_LAST_VERB_EXECUTED) 'error statement
If Err.Number <> 0 Then
Err.Clear
Else
MsgBox (cdoField.Value)
End If
Next




Bhanu said:
Thanks for your reply.

As per your reply, I tried to implement the same in VBA(not using C#.Net).
But, I got an error which is mentioned below.
"cdoPR_LAST_VERB_EXECUTED" is giving error.

Run-time error '-2147221233(8004010f)':
Collaboration Data Objects
[Collaboration Data Objects - [MAPI_E_NOT_FOUND(8004010F)]]

'Code I have implemented
Dim cdoInbox As MAPI.Folder
Dim cdoSession As MAPI.Session
Dim objmsg As MAPI.Message
Dim cdoField As MAPI.Field


Set cdoSession = CreateObject("MAPI.Session")
cdoSession.Logon "outlook", "", False, False
'cdoSession.Logon newSession:=False
Set cdoInbox = cdoSession.Inbox

For Each objmsg In cdoInbox.Messages
Set cdoField = objmsg.Fields(cdoPR_LAST_VERB_EXECUTED) 'error
statement
MsgBox (cdoField.Value)
Next

Do you have any idea as to what could be the reason ?

Thanks
Bhanu



Ken Slovak - said:
The Outlook object model doesn't let you find that. You would need to use
a
different API such as CDO 1.21 or Extended MAPI or Redemption
(www.dimastr.com/redemption). Neither CDO or Extended MAPI can be used
from
..NET languages.

The property you would read would be PR_LAST_VERB_EXECUTED (0x10810003).

EXCHIVERB_REPLYTOSENDER = 102
EXCHIVERB_REPLYTOALL = 103
EXCHIVERB_FORWARD = 104




Iam using C#.net for outlook programming.
I want to know whether a mail is replied/forwarded or not in my Inbox.
Are there any properties like replied/Isreplied/forwarded/Isforwarded
for a MailItem ??
 
K

Ken Slovak - [MVP - Outlook]

You have to handle errors, all errors, in any COM addin. In this case if
there's an error just handle it and clear the error object.

You may run into other problems trying to use CDO 1.21 from a .NET
application. It looks like your code is C# and use of CDO with the COM
Interop is not supported by MS. It might work and it might work most of the
time but you will run into things that just won't work or will fire errors.
 

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