Answered by:
Outlook 2013 automatic send/receive doesn't work with the sample add-in below

Question
-
Hello,
Our customer reported about this problem: intercepting SyncStart/SyncStop events prevents automatic send/receive in Outlook 2013 RTM 32bit and 64bit from working. Below is a simple VSTO add-in demonstrating this problem:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; using Outlook = Microsoft.Office.Interop.Outlook; using Office = Microsoft.Office.Core; using System.Runtime.InteropServices; namespace Outlook2013SyncObjectEvents { public partial class ThisAddIn { private Outlook.SyncObject sync = null; private void ThisAddIn_Startup(object sender, System.EventArgs e) { Outlook.NameSpace ns = this.Application.GetNamespace("MAPI"); if (ns != null) try { Outlook.SyncObjects syncs = ns.SyncObjects; if (syncs != null) try { if (syncs.Count > 0) { sync = syncs[1]; sync.SyncStart += sync_SyncStart; sync.SyncEnd += sync_SyncEnd; } } finally { Marshal.ReleaseComObject(syncs); } } finally { Marshal.ReleaseComObject(ns); } } private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { if (sync != null) Marshal.ReleaseComObject(sync); } private void sync_SyncStart() { // } private void sync_SyncEnd() { // } #region VSTO generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InternalStartup() { this.Startup += new System.EventHandler(ThisAddIn_Startup); this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); } #endregion } }
The test add-in project (VS 2012) can be also downloaded athttp://www.add-in-express.com/files/support/Outlook2013SendReceiveBug.zip.
If the add-in above is registered, the "Schedule an automatic send/receive every XXXX minutes" is regarded as unchecked. To find this option, click the Send/Receive... button (see File | Options | Advanced).
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team Leader
Please mark answers and useful posts to help other developers use the forums efficiently.Tuesday, November 6, 2012 10:35 AM
Answers
-
Hi Andrei,As you probably saw already, Dmitry was also unable to repro the problem.I reported the problem and this forum thead to the product group, and asked if someone could look into the thread.However, I'm pretty sure that you'll be asked to open a support incident that can be escalated for an escalation engineer if someone does look in here. I still think the best way to go on this is to open a support incident and let MS sort it out."Andrei Smolin" <=?utf-8?B?QW5kcmVpIFNtb2xpbg==?=> wrote in message news:0b3c77f1-a35b-46bb-8016-ef831ff66434...
Ken,
Today's result are as follows. Turning our antivirus off didn't help. Turning off all add-ins available by default didn't help. We added message boxes to the VSTO add-in and got the messageboxes shown ... in the reverse order; the message box for the SyncEnd event goes first, then it follows the messagebox for SyncStart. Nevertheless, the actual send/receive opration doesn't start.
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team Leader
Please mark answers and useful posts to help other developers use the forums efficiently.
Ken Slovak MVP - Outlook- Marked as answer by 许阳(无锡) Tuesday, November 13, 2012 6:41 AM
- Unmarked as answer by Andrei Smolin Tuesday, November 13, 2012 8:10 AM
- Marked as answer by Andrei Smolin Friday, December 7, 2012 6:19 AM
Thursday, November 8, 2012 4:37 PM -
Hello All,
The issue was reproduced by Microsoft support engineers using the code sample given at http://msdn.microsoft.com/en-us/library/ff862356%28v=office.15%29.aspx. They don't have a sloution and they will either consider creating a fix or modifying the code sample. In case you have access to their support DB, the ID is 112111310004837.
To complete the picture, I should add that they suggested a workaround: start a new sync in the SyncStart event. Don't feel like this is what we were looking for.
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team Leader
Please mark answers and useful posts to help other developers use the forums efficiently.- Marked as answer by Andrei Smolin Friday, December 7, 2012 6:20 AM
Thursday, December 6, 2012 1:18 PM
All replies
-
Hi Andrei,Let me try to repro this here and then I'll report it to the product group."Andrei Smolin" <=?utf-8?B?QW5kcmVpIFNtb2xpbg==?=> wrote in message news:7a20664c-7650-4d61-9d5f-13f1d929a8cd...
Hello,
Our customer reported about this problem: intercepting SyncStart/SyncStop events prevents automatic send/receive in Outlook 2013 RTM 32bit and 64bit from working. Below is a simple VSTO add-in demonstrating this problem:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; using Outlook = Microsoft.Office.Interop.Outlook; using Office = Microsoft.Office.Core; using System.Runtime.InteropServices; namespace Outlook2013SyncObjectEvents { public partial class ThisAddIn { private Outlook.SyncObject sync = null; private void ThisAddIn_Startup(object sender, System.EventArgs e) { Outlook.NameSpace ns = this.Application.GetNamespace("MAPI"); if (ns != null) try { Outlook.SyncObjects syncs = ns.SyncObjects; if (syncs != null) try { if (syncs.Count > 0) { sync = syncs[1]; sync.SyncStart += sync_SyncStart; sync.SyncEnd += sync_SyncEnd; } } finally { Marshal.ReleaseComObject(syncs); } } finally { Marshal.ReleaseComObject(ns); } } private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { if (sync != null) Marshal.ReleaseComObject(sync); } private void sync_SyncStart() { // } private void sync_SyncEnd() { // } #region VSTO generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InternalStartup() { this.Startup += new System.EventHandler(ThisAddIn_Startup); this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); } #endregion } }
The test add-in project (VS 2012) can be also downloaded athttp://www.add-in-express.com/files/support/Outlook2013SendReceiveBug.zip.
If the add-in above is registered, the "Schedule an automatic send/receive every XXXX minutes" is regarded as unchecked. To find this option, click the Send/Receive... button (see File | Options | Advanced).
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team Leader
Please mark answers and useful posts to help other developers use the forums efficiently.
Ken Slovak MVP - OutlookTuesday, November 6, 2012 5:57 PM -
Hi Andrei,I haven't tried out the VSTO addin test code yet, but I did test equivalent code in the Outlook VBA project. I was not able to repro the bug.I set automatic send/receive in File, Options, Advanced to 5 minutes and then put the following code in ThisOutlookSession:Private WithEvents sync As Outlook.SyncObjectSub InitSyncTest()
Dim oNS As Outlook.NameSpace
Dim syncs As Outlook.SyncObjects
Set sync = Nothing
Set oNS = Application.GetNamespace("MAPI")
Set syncs = oNS.SyncObjects
If (syncs.Count > 0) Then
Set sync = syncs.Item(1)
End If
Set syncs = Nothing
Set oNS = Nothing
End SubPrivate Sub sync_SyncStart()
MsgBox "sync_SyncStart() fired"
End SubPrivate Sub sync_SyncEnd()
MsgBox "sync_SyncEnd() fired"
End SubI ran InitSyncTest() after restarting Outlook and enabling macros , the sync events fired both with manual and automatic send/receives.I tested on Outlook 15.0.4420.1017, MSO 15.0.4420.1017, x86.Please test the VBA code so I can try to figure out if this is an Outlook or VSTO bug.I'll be able to test the addin code using VS 2010 tomorrow. I don't have VS 2012 installed on my Office 2013 VM's yet, so I can't test that combination at this time."Andrei Smolin" <=?utf-8?B?QW5kcmVpIFNtb2xpbg==?=> wrote in message news:7a20664c-7650-4d61-9d5f-13f1d929a8cd...Hello,
Our customer reported about this problem: intercepting SyncStart/SyncStop events prevents automatic send/receive in Outlook 2013 RTM 32bit and 64bit from working. Below is a simple VSTO add-in demonstrating this problem:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; using Outlook = Microsoft.Office.Interop.Outlook; using Office = Microsoft.Office.Core; using System.Runtime.InteropServices; namespace Outlook2013SyncObjectEvents { public partial class ThisAddIn { private Outlook.SyncObject sync = null; private void ThisAddIn_Startup(object sender, System.EventArgs e) { Outlook.NameSpace ns = this.Application.GetNamespace("MAPI"); if (ns != null) try { Outlook.SyncObjects syncs = ns.SyncObjects; if (syncs != null) try { if (syncs.Count > 0) { sync = syncs[1]; sync.SyncStart += sync_SyncStart; sync.SyncEnd += sync_SyncEnd; } } finally { Marshal.ReleaseComObject(syncs); } } finally { Marshal.ReleaseComObject(ns); } } private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { if (sync != null) Marshal.ReleaseComObject(sync); } private void sync_SyncStart() { // } private void sync_SyncEnd() { // } #region VSTO generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InternalStartup() { this.Startup += new System.EventHandler(ThisAddIn_Startup); this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); } #endregion } }
The test add-in project (VS 2012) can be also downloaded athttp://www.add-in-express.com/files/support/Outlook2013SendReceiveBug.zip.
If the add-in above is registered, the "Schedule an automatic send/receive every XXXX minutes" is regarded as unchecked. To find this option, click the Send/Receive... button (see File | Options | Advanced).
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team Leader
Please mark answers and useful posts to help other developers use the forums efficiently.
Ken Slovak MVP - OutlookTuesday, November 6, 2012 9:35 PM -
Hi Andrei,I created a VSTO addin using VS 2010 and replaced the PIA references with Office/Outlook PIA references to the 2013 versions stored in the GAC. I then put your test code in the addin and ran it. The automatic sync events did fire and the automatic send/receive did run at the interval I set in the Outlook settings.So far I've been unable to repro the problem at all with either with VBA, or with C# and VSTO code."Andrei Smolin" <=?utf-8?B?QW5kcmVpIFNtb2xpbg==?=> wrote in message news:7a20664c-7650-4d61-9d5f-13f1d929a8cd...
Hello,
Our customer reported about this problem: intercepting SyncStart/SyncStop events prevents automatic send/receive in Outlook 2013 RTM 32bit and 64bit from working. Below is a simple VSTO add-in demonstrating this problem:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; using Outlook = Microsoft.Office.Interop.Outlook; using Office = Microsoft.Office.Core; using System.Runtime.InteropServices; namespace Outlook2013SyncObjectEvents { public partial class ThisAddIn { private Outlook.SyncObject sync = null; private void ThisAddIn_Startup(object sender, System.EventArgs e) { Outlook.NameSpace ns = this.Application.GetNamespace("MAPI"); if (ns != null) try { Outlook.SyncObjects syncs = ns.SyncObjects; if (syncs != null) try { if (syncs.Count > 0) { sync = syncs[1]; sync.SyncStart += sync_SyncStart; sync.SyncEnd += sync_SyncEnd; } } finally { Marshal.ReleaseComObject(syncs); } } finally { Marshal.ReleaseComObject(ns); } } private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { if (sync != null) Marshal.ReleaseComObject(sync); } private void sync_SyncStart() { // } private void sync_SyncEnd() { // } #region VSTO generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InternalStartup() { this.Startup += new System.EventHandler(ThisAddIn_Startup); this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); } #endregion } }
The test add-in project (VS 2012) can be also downloaded athttp://www.add-in-express.com/files/support/Outlook2013SendReceiveBug.zip.
If the add-in above is registered, the "Schedule an automatic send/receive every XXXX minutes" is regarded as unchecked. To find this option, click the Send/Receive... button (see File | Options | Advanced).
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team Leader
Please mark answers and useful posts to help other developers use the forums efficiently.
Ken Slovak MVP - OutlookWednesday, November 7, 2012 3:38 PM -
Ken,
Thank you. We've retested this add-in: the issue occurs on a POP3/SMTP account only. That is, registering the add-in above prevents the automatic send/receive from working on a POP3/SMTP account in Outlook 2013 32bit and 64bit; the issue isn't reproducible on an Exchange account. We also reproduce the same issue with a Delphi add-in (native code); IOW, this is an Outlook issue, not VSTO.
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team Leader
Please mark answers and useful posts to help other developers use the forums efficiently.Thursday, November 8, 2012 8:35 AM -
Hi Andrei,I did my testing using a POP3/SMTP account, not with an EX account.I'll mention this thread to the product group, but I'll have to say to them that I'm unable to repro the issue myself.Do you have any support incidents available that you could use to open a bug with MS? That might be the best route. In any case, I'll ask if someone can review this thread and let them decide how to proceed.Thanks."Andrei Smolin" <=?utf-8?B?QW5kcmVpIFNtb2xpbg==?=> wrote in message news:f693ef2a-5d94-442e-a852-a1f81934d8db...
Ken,
Thank you. We've retested this add-in: the issue occurs on a POP3/SMTP account only. That is, registering the add-in above prevents the automatic send/receive from working on a POP3/SMTP account in Outlook 2013 32bit and 64bit; the issue isn't reproducible on an Exchange account. We also reproduce the same issue with a Delphi add-in (native code); IOW, this is an Outlook issue, not VSTO.
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team Leader
Please mark answers and useful posts to help other developers use the forums efficiently.
Ken Slovak MVP - OutlookThursday, November 8, 2012 3:22 PM -
I cannot reproduce this problem in OutlookSpy (it subscribes to events on any COM object it displays).
If you browse to the Account objects (click Namespace, select Accounts, click Browse, go to the IEnumVariant tab, open an account from there, go to the Events tab), do you see the events?
I can see the events firing when automatic Send/Receive kicks in.
Dmitry Streblechenko (MVP) http://www.dimastr.com/redemption
Redemption - what the Outlook
Object Model should have been
Version 5.4 is now available!- Edited by Dmitry Streblechenko _MVP_MVP Thursday, November 8, 2012 3:56 PM
Thursday, November 8, 2012 3:47 PM -
Ken,
Today's result are as follows. Turning our antivirus off didn't help. Turning off all add-ins available by default didn't help. We added message boxes to the VSTO add-in and got the messageboxes shown ... in the reverse order; the message box for the SyncEnd event goes first, then it follows the messagebox for SyncStart. Nevertheless, the actual send/receive opration doesn't start.
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team Leader
Please mark answers and useful posts to help other developers use the forums efficiently.Thursday, November 8, 2012 4:24 PM -
Hi Andrei,As you probably saw already, Dmitry was also unable to repro the problem.I reported the problem and this forum thead to the product group, and asked if someone could look into the thread.However, I'm pretty sure that you'll be asked to open a support incident that can be escalated for an escalation engineer if someone does look in here. I still think the best way to go on this is to open a support incident and let MS sort it out."Andrei Smolin" <=?utf-8?B?QW5kcmVpIFNtb2xpbg==?=> wrote in message news:0b3c77f1-a35b-46bb-8016-ef831ff66434...
Ken,
Today's result are as follows. Turning our antivirus off didn't help. Turning off all add-ins available by default didn't help. We added message boxes to the VSTO add-in and got the messageboxes shown ... in the reverse order; the message box for the SyncEnd event goes first, then it follows the messagebox for SyncStart. Nevertheless, the actual send/receive opration doesn't start.
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team Leader
Please mark answers and useful posts to help other developers use the forums efficiently.
Ken Slovak MVP - Outlook- Marked as answer by 许阳(无锡) Tuesday, November 13, 2012 6:41 AM
- Unmarked as answer by Andrei Smolin Tuesday, November 13, 2012 8:10 AM
- Marked as answer by Andrei Smolin Friday, December 7, 2012 6:19 AM
Thursday, November 8, 2012 4:37 PM -
Ken,
Thank you for the suggestion. We are opening a support incident today.
The issue as we see it now is this: if you connect to SyncStart and SyncEnd events, events do work - as Dmitry and you pointed out; the problem is that automatic Send/Receive operations don't deliver mail; this occurs only if you use a POP3/SMTP account.
When I have any news on this, I'll let you know.
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team Leader
Please mark answers and useful posts to help other developers use the forums efficiently.Tuesday, November 13, 2012 8:21 AM -
Hi Andrei,Definitely let me know, but when I tested that I did get emails delivered from automatic send/receives. I just couldn't repro at all."Andrei Smolin" <=?utf-8?B?QW5kcmVpIFNtb2xpbg==?=> wrote in message news:f5b8d6a0-d4db-47fa-8d16-f37d5b310f1e...
Ken,
Thank you for the suggestion. We are opening a support incident today.
The issue as we see it now is this: if you connect to SyncStart and SyncEnd events, events do work - as Dmitry and you pointed out; the problem is that automatic Send/Receive operations don't deliver mail; this occurs only if you use a POP3/SMTP account.
When I have any news on this, I'll let you know.
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team Leader
Please mark answers and useful posts to help other developers use the forums efficiently.
Ken Slovak MVP - OutlookTuesday, November 13, 2012 3:46 PM -
Hi, this seems to be a known Outlook 2013 issue and has been reported by several users already. It seems to be related to POP and IMAP mail boxes only. I have the problem myself too after a clean install of Win8 Pro and Office 2013, even after deactivating all add-ons that are being installed by default.
Thursday, November 15, 2012 7:07 PM -
Hello All,
The issue was reproduced by Microsoft support engineers using the code sample given at http://msdn.microsoft.com/en-us/library/ff862356%28v=office.15%29.aspx. They don't have a sloution and they will either consider creating a fix or modifying the code sample. In case you have access to their support DB, the ID is 112111310004837.
To complete the picture, I should add that they suggested a workaround: start a new sync in the SyncStart event. Don't feel like this is what we were looking for.
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team Leader
Please mark answers and useful posts to help other developers use the forums efficiently.- Marked as answer by Andrei Smolin Friday, December 7, 2012 6:20 AM
Thursday, December 6, 2012 1:18 PM -
Hi Andrei,Thanks for following up on this. Changing the sample code as a solution is a pretty lame idea, in my opinion. A fix is really what's needed, not trying to hide the problem. I also agree that starting a new sync in SyncStart() is not a real solution either."Andrei Smolin" <=?utf-8?B?QW5kcmVpIFNtb2xpbg==?=> wrote in message news:8b1838f3-29fd-4ded-a08b-e3f7a9b128b8...
Hello All,
The issue was reproduced by Microsoft support engineers using the code sample given at http://msdn.microsoft.com/en-us/library/ff862356%28v=office.15%29.aspx. They don't have a sloution and they will either consider creating a fix or modifying the code sample. In case you have access to their support DB, the ID is 112111310004837.
To complete the picture, I should add that they suggested a workaround: start a new sync in the SyncStart event. Don't feel like this is what we were looking for.
Regards from Belarus (GMT + 3),
Andrei Smolin
Add-in Express Team Leader
Please mark answers and useful posts to help other developers use the forums efficiently.
Ken Slovak MVP - OutlookThursday, December 6, 2012 2:53 PM -
Hi,
This issue with Outlook 2013 has been resolved. Please install the following hotfix to correct the issue.
2878323 Description of the Outlook 2013 hotfix package (Outlook-x-none.msp): April 8, 2014
http://support.microsoft.com/kb/2878323/EN-USDo let us know if you have any questions about the above fix.
Best regards,
Nitish [MSFT]
- Proposed as answer by Microsoft Outlook Forum SupportMicrosoft employee Friday, April 18, 2014 3:18 PM
Friday, April 18, 2014 3:18 PM