none
Outlook Add-In RRS feed

  • Question

  • Hi, I am writing an outlook add-in which updates a separate calendar of the user when the user clicks on a sync button (provided as part of the add-in). Now, the issue is, user do not want to stay on the machine every time to click on the sync button in order to update the calendar. Because, user has added his email account on different devices, he would like to receive automatic updates to calendar without him going to the machine to click on the sync button. Please note, this calendar is not a part of the email. It is a separate meeting calendar created personally for the user. The sync button provides updates to the new or changed meetings. Is it possible to automatically execute the c# code within the add-in which will call third party web-service to update the meeting calendar ?

    Bhupinder Singh

    Friday, April 15, 2016 6:32 PM

Answers

  • Hi Bhupinder_Singh

    If we talking about to call the particular code after specific time interval, then you can use timers.

    The example is given below. In which you can see that it will execute after 10 seconds

    class Program
    {
    public static System.Timers.Timer aTimer;
    static void Main(string[] args)
    {
    aTimer = new System.Timers.Timer(10000);
    aTimer.Elapsed += new ElapsedEventHandler(RunThis);
    aTimer.AutoReset = true;
    aTimer.Enabled = true;
    Console.ReadLine();
    }
    private static void RunThis(object source, ElapsedEventArgs e)
    {
    Console.WriteLine("Print this in every 10 seconds");
    }
    }
    
    so you can call it after every 30 min or 1 hour to update your calender.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 20, 2016 7:32 AM
    Moderator
  •  Hi Deepak, 

    Actually, I have found another elegant way of updating outlook folder. I believe I should be using this approach rather than putting some customization on execution of code. I attached (Item Add/Update/Remove) events on my personal calendar within the add-in. So, when the user add/update/remove any event from their device, it will trigger add-in attached events and I can do the rest. However, in this thread, I actually asked for the auto-exection of the event which I believe is the timer code is the answer so I will mark it as answer. Thank you for your help !


    Bhupinder Singh


    Thursday, April 21, 2016 3:13 PM

All replies

  • Hello Singh,

    You can use EWS in case of Exchange. See EWS Managed API, EWS, and web services in Exchange for more information.

    Also you may find Office 365 API helpful. See Get started with Office 365 APIs .


    [custom.development]

    Saturday, April 16, 2016 9:43 AM
  • Hi Bhupinder_Singh,

    are you developing vsto addin or outlook addin?

    Is it possible to automatically execute the c# code

    you can work with threads and batch files which can be called periodically or at specific time in day.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 19, 2016 1:09 AM
    Moderator
  • Hi Deepak, 

    I'm not sure what's the difference between vsto and outlook addin.  But, I created this project in VS as Outlook 2013 Add-in and on publish, it creates AddInName.vsto file.Sorry, I didn't clearly understand how I can do code execution automatically that will make a call to my web-service to update outlook UI (Personal Calendar) ?

    Thanks,

    Bhupinder  


    Bhupinder Singh

    Tuesday, April 19, 2016 4:23 PM
  • Hi Bhupinder_Singh

    If we talking about to call the particular code after specific time interval, then you can use timers.

    The example is given below. In which you can see that it will execute after 10 seconds

    class Program
    {
    public static System.Timers.Timer aTimer;
    static void Main(string[] args)
    {
    aTimer = new System.Timers.Timer(10000);
    aTimer.Elapsed += new ElapsedEventHandler(RunThis);
    aTimer.AutoReset = true;
    aTimer.Enabled = true;
    Console.ReadLine();
    }
    private static void RunThis(object source, ElapsedEventArgs e)
    {
    Console.WriteLine("Print this in every 10 seconds");
    }
    }
    
    so you can call it after every 30 min or 1 hour to update your calender.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 20, 2016 7:32 AM
    Moderator
  • Thanks Deepak, I think this is what I was looking for.

    Is it safe to run the timer code to update Outlook UI ?

    Can I put timer on add-in start event ?

             

     

     private void ThisAddIn_Startup(object sender, System.EventArgs e) {  /// timer code}


    Wednesday, April 20, 2016 6:41 PM
  • Hi Bhupinder_Singh,

    you want to know that you can execute timer on startup event of addin or not.

    yes you can execute timer on the startup event of addin.

    it will run exactly as we run it in different applications.

    it will run continuously in your addin. and we can use it to perform repetitive task after predefine interval.

    Regards

    Deepak  


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, April 21, 2016 4:35 AM
    Moderator
  • Thank you Deepak. I was thinking in terms of the behavior of the add-in whether it should be on the start event or not. Because, I am thinking to call a long running operation on the timer code which I assume may delay the add-in to load with Outlook application, and it may possibly auto-disable my add-in due to the performance. 

    Bhupinder Singh


    Thursday, April 21, 2016 2:53 PM
  •  Hi Deepak, 

    Actually, I have found another elegant way of updating outlook folder. I believe I should be using this approach rather than putting some customization on execution of code. I attached (Item Add/Update/Remove) events on my personal calendar within the add-in. So, when the user add/update/remove any event from their device, it will trigger add-in attached events and I can do the rest. However, in this thread, I actually asked for the auto-exection of the event which I believe is the timer code is the answer so I will mark it as answer. Thank you for your help !


    Bhupinder Singh


    Thursday, April 21, 2016 3:13 PM