After Office 2007 SP2 install - Outlook 2007 macro no longer worki

  • Thread starter cnByYXRpa25v
  • Start date Views 3,057
Status
Not open for further replies.
C

cnByYXRpa25v

Hi guys,

I have a macro that will move all email sent with "sendonbehalf" properties

to the group mailbox. I found it on someone post and it has been working like

a charm until I installed Office SP2. It doesn't work anymore. Do anyone

might know what is the issue? I have try re-install Office then also SP2 with

no joy.

Below is the code

Private SentEntryID As String

Private SentStoreID As String

Private WithEvents objSentItems As Items

Private MailItem As Outlook.MailItem

Public Sub Application_Startup()

'Retrieve ID for accessing non-default sent folder

getStoreFolderID ("Mailbox - group")

Set objSentItems =

Application.Session.GetDefaultFolder(olFolderSentMail).Items

End Sub

Function getStoreFolderID(StoreName)

'Gets the Shared Account Sent Folder

Dim Store As Object

Dim StoreFolder As Object

Dim i As Integer

Set Store = Application.GetNamespace("mapi").Folders

For Each StoreFolder In Store

If StoreFolder.Name = StoreName Then

For i = 1 To StoreFolder.Folders.Count

If StoreFolder.Folders(i).Name = "Sent Items" Then

SentEntryID = StoreFolder.Folders(i).EntryID

SentStoreID = StoreFolder.Folders(i).StoreID

Exit For

End If

Next

Exit For

End If

Next

Set Store = Nothing

Set StoreFolder = Nothing

End Function

Private Sub objSentItems_ItemAdd(ByVal Item As Object)

'Fired when something is added to personal "Sent Mail" folder

If TypeOf Item Is Outlook.MailItem Then

With Item

Set MailItem = Application.GetNamespace("mapi").GetItemFromID(.EntryID,

> .Parent.StoreID)

End With

If MailItem.SentOnBehalfOfName = "group" Then

Set DestinationFolder = Application.Session.GetFolderFromID(SentEntryID,

SentStoreID)

MailItem.Move (DestinationFolder)

End If

End If

Set MailItem = Nothing

End Sub

Any suggestion or thinking are welcomed.

Thanks.
 
K

Ken Slovak - [MVP - Outlook]

Doesn't work in what way? Does the code run at all? What if you run it

manually, do you get any errors? Which line or lines throw errors?

"rpratikno" <rpratikno> wrote in message

news:D47D1D48-7EEF-4C05-9F04-073BC1AEBF63@microsoft.com...
> Hi guys,

> I have a macro that will move all email sent with "sendonbehalf"
> properties
> to the group mailbox. I found it on someone post and it has been working
> like
> a charm until I installed Office SP2. It doesn't work anymore. Do anyone
> might know what is the issue? I have try re-install Office then also SP2
> with
> no joy.

> Below is the code
> Private SentEntryID As String
> Private SentStoreID As String
> Private WithEvents objSentItems As Items
> Private MailItem As Outlook.MailItem

> Public Sub Application_Startup()
> 'Retrieve ID for accessing non-default sent folder
> getStoreFolderID ("Mailbox - group")
> Set objSentItems =
> Application.Session.GetDefaultFolder(olFolderSentMail).Items
> End Sub

> Function getStoreFolderID(StoreName)
> 'Gets the Shared Account Sent Folder
> Dim Store As Object
> Dim StoreFolder As Object
> Dim i As Integer
> Set Store = Application.GetNamespace("mapi").Folders
> For Each StoreFolder In Store
> If StoreFolder.Name = StoreName Then
> For i = 1 To StoreFolder.Folders.Count
> If StoreFolder.Folders(i).Name = "Sent Items" Then
> SentEntryID = StoreFolder.Folders(i).EntryID
> SentStoreID = StoreFolder.Folders(i).StoreID
> Exit For
> End If
> Next
> Exit For
> End If
> Next
> Set Store = Nothing
> Set StoreFolder = Nothing
> End Function

> Private Sub objSentItems_ItemAdd(ByVal Item As Object)
> 'Fired when something is added to personal "Sent Mail" folder
> If TypeOf Item Is Outlook.MailItem Then
> With Item
> Set MailItem = Application.GetNamespace("mapi").GetItemFromID(.EntryID,
> .Parent.StoreID)
> End With
> If MailItem.SentOnBehalfOfName = "group" Then
> Set DestinationFolder = Application.Session.GetFolderFromID(SentEntryID,
> SentStoreID)
> MailItem.Move (DestinationFolder)
> End If
> End If
> Set MailItem = Nothing
> End Sub

> Any suggestion or thinking are welcomed.

> Thanks.
 
C

cnByYXRpa25v

Re: After Office 2007 SP2 install - Outlook 2007 macro no longer w

Hi Ken,

Thanks for replying.

It no longer move sent email automatically to "group" mailbox, the sent

email is sitting on individual users mailbox.

If I run it manually it didn't throw any error message at all.

Thank you.
wrote:


> Doesn't work in what way? Does the code run at all? What if you run it
> manually, do you get any errors? Which line or lines throw errors?

> >

>

> "rpratikno" <rpratikno> wrote in message
> news:D47D1D48-7EEF-4C05-9F04-073BC1AEBF63@microsoft.com...
> > Hi guys,
> > I have a macro that will move all email sent with "sendonbehalf"
> > properties
> > to the group mailbox. I found it on someone post and it has been working
> > like
> > a charm until I installed Office SP2. It doesn't work anymore. Do anyone
> > might know what is the issue? I have try re-install Office then also SP2
> > with
> > no joy.
> > Below is the code
> > Private SentEntryID As String
> > Private SentStoreID As String
> > Private WithEvents objSentItems As Items
> > Private MailItem As Outlook.MailItem
> > Public Sub Application_Startup()
> > 'Retrieve ID for accessing non-default sent folder
> > getStoreFolderID ("Mailbox - group")
> > Set objSentItems =
> > Application.Session.GetDefaultFolder(olFolderSentMail).Items
> > End Sub
> > Function getStoreFolderID(StoreName)
> > 'Gets the Shared Account Sent Folder
> > Dim Store As Object
> > Dim StoreFolder As Object
> > Dim i As Integer
> > Set Store = Application.GetNamespace("mapi").Folders
> > For Each StoreFolder In Store
> > If StoreFolder.Name = StoreName Then
> > For i = 1 To StoreFolder.Folders.Count
> > If StoreFolder.Folders(i).Name = "Sent Items" Then
> > SentEntryID = StoreFolder.Folders(i).EntryID
> > SentStoreID = StoreFolder.Folders(i).StoreID
> > Exit For
> > End If
> > Next
> > Exit For
> > End If
> > Next
> > Set Store = Nothing
> > Set StoreFolder = Nothing
> > End Function
> > Private Sub objSentItems_ItemAdd(ByVal Item As Object)
> > 'Fired when something is added to personal "Sent Mail" folder
> > If TypeOf Item Is Outlook.MailItem Then
> > With Item
> > Set MailItem = Application.GetNamespace("mapi").GetItemFromID(.EntryID,
> > .Parent.StoreID)
> > End With
> > If MailItem.SentOnBehalfOfName = "group" Then
> > Set DestinationFolder = Application.Session.GetFolderFromID(SentEntryID,
> > SentStoreID)
> > MailItem.Move (DestinationFolder)
> > End If
> > End If
> > Set MailItem = Nothing
> > End Sub
> > Any suggestion or thinking are welcomed.
> > Thanks.


>
 
K

Ken Slovak - [MVP - Outlook]

Re: After Office 2007 SP2 install - Outlook 2007 macro no longer w

What I'd do in that case is to put some Debug.Print statements in the code

in the startup initializer and the code that's supposed to be called and see

where the statements fail to write to the Immediate window and the code is

failing. I'd also set up breakpoints in the getStoreFolderID() and

objSentItems_ItemAdd() methods and send some test messages that should

trigger your code and see what happens. That's about the only way to figure

out what's going on.

"rpratikno" <rpratikno> wrote in message

news:AEEE6080-B65B-4605-940E-ED3B29AF1425@microsoft.com...
> Hi Ken,

> Thanks for replying.

> It no longer move sent email automatically to "group" mailbox, the sent
> email is sitting on individual users mailbox.

> If I run it manually it didn't throw any error message at all.

> Thank you.
 
C

cnByYXRpa25v

Re: After Office 2007 SP2 install - Outlook 2007 macro no longer w

Hi Ken,

Thanks for the tips to start debugging =) I manage to found the cause.

After installing Outlook SP2, if we reply any group email on group mailbox,

the email From field will no longer contain SendOnBehalf properties, which

definitely break the macro.

Do you have any suggestion to fix it?

Thanks.
wrote:


> What I'd do in that case is to put some Debug.Print statements in the code
> in the startup initializer and the code that's supposed to be called and see
> where the statements fail to write to the Immediate window and the code is
> failing. I'd also set up breakpoints in the getStoreFolderID() and
> objSentItems_ItemAdd() methods and send some test messages that should
> trigger your code and see what happens. That's about the only way to figure
> out what's going on.

> >

>

> "rpratikno" <rpratikno> wrote in message
> news:AEEE6080-B65B-4605-940E-ED3B29AF1425@microsoft.com...
> > Hi Ken,
> > Thanks for replying.
> > It no longer move sent email automatically to "group" mailbox, the sent
> > email is sitting on individual users mailbox.
> > If I run it manually it didn't throw any error message at all.
> > Thank you.


>
 
K

Ken Slovak - [MVP - Outlook]

Re: After Office 2007 SP2 install - Outlook 2007 macro no longer w

I'm sorry, I can't reproduce that at all.

I tested with Outlook 2007 SP2 and any reply from a shared mailbox using the

From as the shared mailbox alias always provided SentOnBehalfOfName and the

equivalent MAPI property in the items going to Sent Items in the default

mailbox.

Original emails using that From also had that property on them.

"rpratikno" <rpratikno> wrote in message

news:DF59BC0E-7491-42EB-8BF2-E286C257F511@microsoft.com...
> Hi Ken,

> Thanks for the tips to start debugging =) I manage to found the cause.

> After installing Outlook SP2, if we reply any group email on group
> mailbox,
> the email From field will no longer contain SendOnBehalf properties, which
> definitely break the macro.

> Do you have any suggestion to fix it?

> Thanks.
 
S

Sue Mosher [MVP]

Re: After Office 2007 SP2 install - Outlook 2007 macro no longer w

Ken, just curious: If you reply from the mailbox, is the From field in the

UI already filled in with the mailbox name? Or does the user have to fill it

in manually?

Sue Mosher
<kenslovak@mvps.org> wrote in message

news:updvTII2JHA.1416@TK2MSFTNGP04.phx.gbl...
> I'm sorry, I can't reproduce that at all.

> I tested with Outlook 2007 SP2 and any reply from a shared mailbox using
> the From as the shared mailbox alias always provided SentOnBehalfOfName
> and the equivalent MAPI property in the items going to Sent Items in the
> default mailbox.

> Original emails using that From also had that property on them.

> >

>

> "rpratikno" <rpratikno> wrote in message
> news:DF59BC0E-7491-42EB-8BF2-E286C257F511@microsoft.com...
> > Hi Ken,
>

>> Thanks for the tips to start debugging =) I manage to found the cause.
>

>> After installing Outlook SP2, if we reply any group email on group
> > mailbox,
> > the email From field will no longer contain SendOnBehalf properties,
> > which
> > definitely break the macro.
>

>> Do you have any suggestion to fix it?
>

>> Thanks.

>
 
K

Ken Slovak - [MVP - Outlook]

Re: After Office 2007 SP2 install - Outlook 2007 macro no longer w

In replying from the mailbox the From is already filled in with the mailbox

SMTP address.

"Sue Mosher [MVP]" <suemvp@turtleflock.com> wrote in message

news:eugNQfI2JHA.1372@TK2MSFTNGP05.phx.gbl...
> Ken, just curious: If you reply from the mailbox, is the From field in the
> UI already filled in with the mailbox name? Or does the user have to fill
> it in manually?

> > Sue Mosher
> > >
 
C

cnByYXRpa25v

Re: After Office 2007 SP2 install - Outlook 2007 macro no longer w

Hi Ken,

Thanks for trying to reproduce my scenario, I appreciate that. Could you

please define which one is default mailbox? I assume default mailbox is the

sender mailbox, not the shared mailbox. Please correct me if I'm wrong.

The goal of this macro is to automatically move all email that a user reply

from shared mailbox into shared mailbox's sent items, not to the user

sender/default sent items.

I used Macro "watch" to see string value on the MailItem property. When I

hit reply on shared mailbox's email, the MailItem's SharedOnBehalfOfName

property string value is the user's name instead of the shared mailbox's name.

I did check what the recipient see on their side, the email From field is

"user on behalf of shared". On sender side (me) the email From field is only

"user" without "on behalf of shared". So I'm positive the issue is on Outlook

instead of Exchange server. I got 10 users having the same issue here.

Could you please assist me more further? Your help is much appreciated.
wrote:


> I'm sorry, I can't reproduce that at all.

> I tested with Outlook 2007 SP2 and any reply from a shared mailbox using the
> From as the shared mailbox alias always provided SentOnBehalfOfName and the
> equivalent MAPI property in the items going to Sent Items in the default
> mailbox.

> Original emails using that From also had that property on them.

> >

>

> "rpratikno" <rpratikno> wrote in message
> news:DF59BC0E-7491-42EB-8BF2-E286C257F511@microsoft.com...
> > Hi Ken,
> > Thanks for the tips to start debugging =) I manage to found the cause.
> > After installing Outlook SP2, if we reply any group email on group
> > mailbox,
> > the email From field will no longer contain SendOnBehalf properties, which
> > definitely break the macro.
> > Do you have any suggestion to fix it?
> > Thanks.


>
 
K

Ken Slovak - [MVP - Outlook]

Re: After Office 2007 SP2 install - Outlook 2007 macro no longer w

I told you already that I tested this on Outlook 2007 SP2 and did not find

what you are finding. So it is not a bug in Outlook 2007 SP2. Why you see

the results you see I have no idea, but if it was a bug in the service pack

I'd see it here also on the 2 computers I tested on.

"rpratikno" <rpratikno> wrote in message

news:E5A881B9-537B-44AB-BC06-8AF1105EED60@microsoft.com...
> Hi Ken,

> Thanks for replying.

> I do understand your explanation are what the Exchange features and
> default.
> When you reply email on Sales mailbox, the email that you sent will go to
> the
> profile sent items, which is not what our organisation want. That is the
> reason I use the macro, we want the sent email of replying Sales mailbox
> not
> to the profile's Sent Items, yet to the Sales mailbox's sent items.

> What I found is on Outlook side (not Exchange), with Outlook SP2, the
> SendOnBehalfOfName property is no longer contain the Sales' name. It is
> now
> contain profile's name. This is not happening before Outlook SP2, I'm
> wondering if this is a bug on Office SP2? I didn't make any changes on the
> macro code. The exactly same macro works fine prior to Office SP2.

> However, at the reply email receiver the sender name is correct, which is
> "profile on behalf of sales". So I'm sure this is not the problem of
> Exchange
> configuration.

> Will you be able to confirm that this is a bug on Office SP2? Please do
> correct me if I'm wrong.

> Thank you very much for your thinking, it is much appreciated.
 
Y

YmZveGFsbA

Re: After Office 2007 SP2 install - Outlook 2007 macro no longer w

"rpratikno" wrote:


> Hi Ken,

> Thanks for trying to reproduce my scenario, I appreciate that. Could you
> please define which one is default mailbox? I assume default mailbox is the
> sender mailbox, not the shared mailbox. Please correct me if I'm wrong.

> The goal of this macro is to automatically move all email that a user reply
> from shared mailbox into shared mailbox's sent items, not to the user
> sender/default sent items.

> I used Macro "watch" to see string value on the MailItem property. When I
> hit reply on shared mailbox's email, the MailItem's SharedOnBehalfOfName
> property string value is the user's name instead of the shared mailbox's name.

> I did check what the recipient see on their side, the email From field is
> "user on behalf of shared". On sender side (me) the email From field is only
> "user" without "on behalf of shared". So I'm positive the issue is on Outlook
> instead of Exchange server. I got 10 users having the same issue here.

> Could you please assist me more further? Your help is much appreciated.

> " - " wrote:
>
> > I'm sorry, I can't reproduce that at all.
> > I tested with Outlook 2007 SP2 and any reply from a shared mailbox using the
> > From as the shared mailbox alias always provided SentOnBehalfOfName and the
> > equivalent MAPI property in the items going to Sent Items in the default
> > mailbox.
> > Original emails using that From also had that property on them.
> > > >

> >

> > "rpratikno" <rpratikno> wrote in message
> > news:DF59BC0E-7491-42EB-8BF2-E286C257F511@microsoft.com...
> > > Hi Ken,
> > > > Thanks for the tips to start debugging =) I manage to found the cause.
> > > > After installing Outlook SP2, if we reply any group email on group
> > > mailbox,
> > > the email From field will no longer contain SendOnBehalf properties, which
> > > definitely break the macro.
> > > > Do you have any suggestion to fix it?
> > > > Thanks.

> >
 
P

Perfort

I have the same problem.

I don't use your macro but a com plugin UniSent (same issue)

If you start a mail from scratch the problem doesn't exist

If you <clear FromField> + <Retype what was there> the problem doesn't exist

(Actually its enough to just hit <enter> in the AutoPoppulated FromField).

Big problem hope someone can solve it.

:) Morten

"rpratikno" wrote:


> Hi guys,

> I have a macro that will move all email sent with "sendonbehalf" properties
> to the group mailbox. I found it on someone post and it has been working like
> a charm until I installed Office SP2. It doesn't work anymore. Do anyone
> might know what is the issue? I have try re-install Office then also SP2 with
> no joy.

> Below is the code
> Private SentEntryID As String
> Private SentStoreID As String
> Private WithEvents objSentItems As Items
> Private MailItem As Outlook.MailItem

> Public Sub Application_Startup()
> 'Retrieve ID for accessing non-default sent folder
> getStoreFolderID ("Mailbox - group")
> Set objSentItems =
> Application.Session.GetDefaultFolder(olFolderSentMail).Items
> End Sub

> Function getStoreFolderID(StoreName)
> 'Gets the Shared Account Sent Folder
> Dim Store As Object
> Dim StoreFolder As Object
> Dim i As Integer
> Set Store = Application.GetNamespace("mapi").Folders
> For Each StoreFolder In Store
> If StoreFolder.Name = StoreName Then
> For i = 1 To StoreFolder.Folders.Count
> If StoreFolder.Folders(i).Name = "Sent Items" Then
> SentEntryID = StoreFolder.Folders(i).EntryID
> SentStoreID = StoreFolder.Folders(i).StoreID
> Exit For
> End If
> Next
> Exit For
> End If
> Next
> Set Store = Nothing
> Set StoreFolder = Nothing
> End Function

> Private Sub objSentItems_ItemAdd(ByVal Item As Object)
> 'Fired when something is added to personal "Sent Mail" folder
> If TypeOf Item Is Outlook.MailItem Then
> With Item
> Set MailItem = Application.GetNamespace("mapi").GetItemFromID(.EntryID,
> .Parent.StoreID)
> End With
> If MailItem.SentOnBehalfOfName = "group" Then
> Set DestinationFolder = Application.Session.GetFolderFromID(SentEntryID,
> SentStoreID)
> MailItem.Move (DestinationFolder)
> End If
> End If
> Set MailItem = Nothing
> End Sub

> Any suggestion or thinking are welcomed.

> Thanks.
 
Status
Not open for further replies.
Top