dweeks

Outlook 2007 VSTO Add-in.

The code (below) works fine... and the items do send, but they appear in my Outbox forever. Can anyone offer help in getting the notes to send and to not have them sit in the Outbox Thanks!

Here is the code:

Private Sub Application_ItemSend(ByVal Item As Object, ByRef Cancel As Boolean) Handles Application.ItemSend
If TypeOf (Item) Is MeetingItem Then
SyncMe(Item)

End If

End Sub


Private Sub SyncMe(ByVal Item As Object)
Dim r As Recipient
Dim AmIThere As Boolean = False

For Each r In Item.recipients
If LCase(r.Address) = "MyOtherEmail@Someplace.com
" Then
AmIThere = True
Exit For
End If
Next

If AmIThere = False Then
Item.recipients.add("
MyOtherEmail@Someplace.com")
End If

End Sub



Re: Visual Studio Tools for Office Outbox Frustration

Sue Mosher - Outlook MVP

Have you tried resolving the additional recipient:

Set r = Item.recipients.add("MyOtherEmail@Someplace.com")

r.Resolve

BTW, the way you have it AmIThere will always be false. You should change this statement:

If LCase(r.Address) = "MyOtherEmail@Someplace.com" Then

to

If LCase(r.Address) = "myotheremail@someplace.com" Then

Also, you should check to see that the SaveSentMessageFolder property is not set to an invalid folder reference.





Re: Visual Studio Tools for Office Outbox Frustration

dweeks

I appreciate your trying to help.

1 - I may be missing something, but I thought the Resolve method just checked to see if the recipient can be resolved any valid entry in the Address Book. I'm trying to check for a specific email address.

2 - Yes, the code example I posted will always be false... sorry. I replaced the actual "other email address" from my code with a generic MyOtherEmail@Someplace.com when posting the note... so my real email address wouldn't be posted as part of the code...

3 - Your last point is really confusing me. If I create a meeting item, I can see the SaveSentMessageFolder property. But if I look at the Item passed in by the application to the Application_ItemSend event, it does identify it as a MeetingItem (using the TypeOf method), but it does not seem to have a SaveSentMessageFolder property.

dw





Re: Visual Studio Tools for Office Outbox Frustration

Sue Mosher - Outlook MVP

1) All addresses must be resolved before a message can be sent. Some versions of Outlook will not send a message where an address has been added programmatically but not explicitly resolved. Therefore, it's always a good idea to resolve explicitly, rather than assume Outlook will do it for you.

2) Just make sure your address string is lower-case.

3) Sorry, I forgot that your code was operating only on MeetingItem objects, which don't have a SaveSentMessageFolder property. I was pointing out that property, because I've seen messages not get filed to Sent Items because that property had an invalid value.

Do you have any other add-ins running If so, disable them to see if perhaps they're responsible.





Re: Visual Studio Tools for Office Outbox Frustration

Mike Walker

Hi

First suggestion like Sue says is to see if any other addins are affecting things, the next thing is to create a standard Event handler and rem all of your code and see whether the API hook is causing this issue, The last thing I would suggest and have seen before is making sure you are using the PIA's (Primary Interop Assemblies) http://www.microsoft.com/downloads/details.aspx familyid=3c9a983a-ac14-4125-8ba0-d36d67e0f4ad is the office 2003 download. If you have a blank method IE No code in the handler and this still fails the send of the item then Try reinstalling the PIA's and making sure you re-reference your Office COM Objects in the solution.

Regards






Re: Visual Studio Tools for Office Outbox Frustration

Mike Walker

Ah

I may have seen the problem now, it is worth working with the object as the correct type you validate to see if the object is MeetingItem type I would suggest you work on the object as this type just in case there is Resolve function is firing an error and VB Runtime Compiler is ignoring this - VB gets away with a lot of things if late bound.

Regards






Re: Visual Studio Tools for Office Outbox Frustration

Sue Mosher - Outlook MVP

To add some specifics to Mike's suggestion, you'd want to declare and use a MeetingItem object:

Code Snippet

Private Sub Application_ItemSend(ByVal Item As Object, ByRef Cancel As Boolean) Handles Application.ItemSend

Dim mtg as Outlook.MeetingItem
If TypeOf (Item) Is MeetingItem Then

mtg = Item
SyncMe(mtg)

End If

End Sub


Private Sub SyncMe(ByVal Item As Outlook.MeetingItem)
Dim r As Recipient
Dim AmIThere As Boolean = False

For Each r In Item.Recipients
If LCase(r.Address) = "mylowercaseemail@someplace.com
" Then
AmIThere = True
Exit For
End If
Next

If AmIThere = False Then
r = Item.recipients.add("
MyOtherEmail@Someplace.com")

r.Resolve
End If

End Sub