Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Losing handle to MailItem when send

Geek News

Losing handle to MailItem when send
"donald" <jonathan[ at ]dorling.biz> 2/1/2006 3:47:33 PM
If you access Outlook through COM-automation and create a new MailItem,
you lose access to it when it is send.

"The subject has been moved or deleted" or some such error message you
get, if you try to access any of the mails properties after it has been
send.

I know i need to keep track of the MailItem where it is using
MAPIFolder.Items.ItemAdd event on the "Sent Items" folder and add a
unique custom property to the message and then search for that message
in the "Sent Items" folder.

I got the ItemAdd and it find it but i need to check it is the right
message so how can i add a custom property to all the MailItem in
outlook?

Thanks

Donald

Re: Losing handle to MailItem when send
"Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> 2/1/2006 3:52:52 PM
You should be able to use the Application_ItemSend event handler to add a custom property.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"donald" <jonathan[ at ]dorling.biz> wrote in message news:1138808853.762528.129670[ at ]g43g2000cwa.googlegroups.com...
[Quoted Text]
> If you access Outlook through COM-automation and create a new MailItem,
> you lose access to it when it is send.
>
> "The subject has been moved or deleted" or some such error message you
> get, if you try to access any of the mails properties after it has been
> send.
>
> I know i need to keep track of the MailItem where it is using
> MAPIFolder.Items.ItemAdd event on the "Sent Items" folder and add a
> unique custom property to the message and then search for that message
> in the "Sent Items" folder.
>
> I got the ItemAdd and it find it but i need to check it is the right
> message so how can i add a custom property to all the MailItem in
> outlook?
>
> Thanks
>
> Donald
>
Re: Losing handle to MailItem when send
"donald" <jonathan[ at ]dorling.biz> 2/1/2006 4:26:53 PM
I could do it with that yes but i would like to do it with ItemAdd
because i basic set it all up now. i am putting the custom property in
side Mileage but i can't read what is in Mileage i get a error about
late binding

this is my code:

Private Sub currentoutbox_ItemAdd(ByVal Item As Object) Handles
currentoutbox.ItemAdd

Dim subject As String
Dim Mileage As String

subject = Item.Subject

Try
Mileage = Item.Mileage
Catch ex As Exception
MsgBox(ex.ToString)
End Try

End Sub

Re: Losing handle to MailItem when send
"Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> 2/1/2006 4:46:59 PM
Never, ever change items in the Outbox. Either change them in the Sent Items folder or use Application_ItemSend.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"donald" <jonathan[ at ]dorling.biz> wrote in message news:1138811212.988076.113710[ at ]f14g2000cwb.googlegroups.com...
[Quoted Text]
>I could do it with that yes but i would like to do it with ItemAdd
> because i basic set it all up now. i am putting the custom property in
> side Mileage but i can't read what is in Mileage i get a error about
> late binding
>
> this is my code:
>
> Private Sub currentoutbox_ItemAdd(ByVal Item As Object) Handles
> currentoutbox.ItemAdd
>
> Dim subject As String
> Dim Mileage As String
>
> subject = Item.Subject
>
> Try
> Mileage = Item.Mileage
> Catch ex As Exception
> MsgBox(ex.ToString)
> End Try
>
> End Sub
>
Re: Losing handle to MailItem when send
"donald" <jonathan[ at ]dorling.biz> 2/1/2006 4:54:19 PM
i am chnaging that in the Sent Items

i have currentoutbox = _NameSpace.Folders.Item("MailBox -
XXXXXXXXXX").Folders("Sent Items").Items

Re: Losing handle to MailItem when send
"Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> 2/1/2006 4:58:13 PM
But you're using the Add event on the OUtbox's Items collection:

[Quoted Text]
> Private Sub currentoutbox_ItemAdd(ByVal Item As Object) Handles
> currentoutbox.ItemAdd

Never use that folder's ItemAdd event. Use the ItemAdd event in Sent Items or use Application_ItemSend.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"donald" <jonathan[ at ]dorling.biz> wrote in message news:1138812859.726620.67580[ at ]z14g2000cwz.googlegroups.com...
>i am chnaging that in the Sent Items
>
> i have currentoutbox = _NameSpace.Folders.Item("MailBox -
> XXXXXXXXXX").Folders("Sent Items").Items
>
Re: Losing handle to MailItem when send
"donald" <jonathan[ at ]dorling.biz> 2/1/2006 5:03:45 PM
i am loss here

what folder do i do ItemAdd event on and what type do i have it on??

Donald

Re: Losing handle to MailItem when send
"Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> 2/1/2006 5:17:56 PM
This statement in the snippet you posted suggests that you're trying to process items as they are added to the Outbox, although you don't show the derivation of your "currentoutbox" object:

Private Sub currentoutbox_ItemAdd(ByVal Item As Object) _
Handles currentoutbox.ItemAdd

Repeating: Never use the Outbox folder's ItemAdd event. Use the ItemAdd event for the Sent Items folder or use Application_ItemSend.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"donald" <jonathan[ at ]dorling.biz> wrote in message news:1138813425.015774.47100[ at ]g47g2000cwa.googlegroups.com...
[Quoted Text]
>i am loss here
>
> what folder do i do ItemAdd event on and what type do i have it on??
>
> Donald
>
Re: Losing handle to MailItem when send
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 2/1/2006 6:09:56 PM
Application.ItemSend event fires before the mesasge is first moved to the
Outbox and then to the Sent Items folder, so you you can safely add your
custom prop in that event handler.

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

"donald" <jonathan[ at ]dorling.biz> wrote in message
news:1138808853.762528.129670[ at ]g43g2000cwa.googlegroups.com...
[Quoted Text]
> If you access Outlook through COM-automation and create a new MailItem,
> you lose access to it when it is send.
>
> "The subject has been moved or deleted" or some such error message you
> get, if you try to access any of the mails properties after it has been
> send.
>
> I know i need to keep track of the MailItem where it is using
> MAPIFolder.Items.ItemAdd event on the "Sent Items" folder and add a
> unique custom property to the message and then search for that message
> in the "Sent Items" folder.
>
> I got the ItemAdd and it find it but i need to check it is the right
> message so how can i add a custom property to all the MailItem in
> outlook?
>
> Thanks
>
> Donald
>


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