2013년 2월 21일 목요일

vsto Outlook Add Custom Menus


vsto Outlook Add Custom Menus

아웃룩 Add-in 메뉴 추가하기


How to: Add Custom Menus and Menu Items to Outlook
http://msdn.microsoft.com/en-us/library/ms269110(v=vs.80).aspx


Extending the User Interface in Outlook 2010
http://msdn.microsoft.com/en-us/library/ee692172.aspx#OfficeOLExtendingUI_ContextMenuforaMailItem


How to: Add Custom Toolbars and Toolbar Items to Outlook
http://msdn.microsoft.com/en-US/library/ms268864(v=vs.80).aspx

2013년 2월 19일 화요일

Programmatically Determine the Current Outlook Item


Programmatically Determine the Current Outlook Item

현재 아웃룩 선택 폴더.

삭제이벤트시 사용하자


This example uses the Explorer.SelectionChange event to display the name of the current folder and some information about the selected item. The code then displays the selected item.
Applies to: The information in this topic applies to application-level projects for Outlook 2013 and Outlook 2010. For more information, see Features Available by Office Application and Project Type.
        Outlook.Explorer currentExplorer = null;

        private void ThisAddIn_Startup
            (object sender, System.EventArgs e)
        {
            currentExplorer = this.Application.ActiveExplorer();
            currentExplorer.SelectionChange += new Outlook
                .ExplorerEvents_10_SelectionChangeEventHandler
                (CurrentExplorer_Event);
        }

        private void CurrentExplorer_Event()
        {
            Outlook.MAPIFolder selectedFolder =
                this.Application.ActiveExplorer().CurrentFolder;
            String expMessage = "Your current folder is "
                + selectedFolder.Name + ".\n";
            String itemMessage = "Item is unknown.";
            try
            {
                if (this.Application.ActiveExplorer().Selection.Count > 0)
                {
                    Object selObject = this.Application.ActiveExplorer().Selection[1];
                    if (selObject is Outlook.MailItem)
                    {
                        Outlook.MailItem mailItem =
                            (selObject as Outlook.MailItem);
                        itemMessage = "The item is an e-mail message." +
                            " The subject is " + mailItem.Subject + ".";
                        mailItem.Display(false);
                    }
                    else if (selObject is Outlook.ContactItem)
                    {
                        Outlook.ContactItem contactItem =
                            (selObject as Outlook.ContactItem);
                        itemMessage = "The item is a contact." +
                            " The full name is " + contactItem.Subject + ".";
                        contactItem.Display(false);
                    }
                    else if (selObject is Outlook.AppointmentItem)
                    {
                        Outlook.AppointmentItem apptItem =
                            (selObject as Outlook.AppointmentItem);
                        itemMessage = "The item is an appointment." +
                            " The subject is " + apptItem.Subject + ".";
                    }
                    else if (selObject is Outlook.TaskItem)
                    {
                        Outlook.TaskItem taskItem =
                            (selObject as Outlook.TaskItem);
                        itemMessage = "The item is a task. The body is "
                            + taskItem.Body + ".";
                    }
                    else if (selObject is Outlook.MeetingItem)
                    {
                        Outlook.MeetingItem meetingItem =
                            (selObject as Outlook.MeetingItem);
                        itemMessage = "The item is a meeting item. " +
                             "The subject is " + meetingItem.Subject + ".";
                    }
                }
                expMessage = expMessage + itemMessage;
            }
            catch (Exception ex)
            {
                expMessage = ex.Message;
            }
            MessageBox.Show(expMessage);
        }
This example requires:
  • Appointment, contact, and e-mail items in Microsoft Office Outlook.



http://msdn.microsoft.com/en-us/library/vstudio/ms268994.aspx

2013년 2월 17일 일요일

오피스365 webservice call in C#

오피스365 webservice call in C#



How to call Office365 web service in a Console application using WCF

오피스365 webservice 를 호출하는 방법 입니다. 

  1. static void Main(string[] args)  
  2. {  
  3. MsOnlineClaimsHelper claimsHelper = new MsOnlineClaimsHelper( "admin@ybbest.onmicrosoft.com""YourPassword","https://ybbest.sharepoint.com/");  
  4. HttpRequestMessageProperty p = new HttpRequestMessageProperty();  
  5. var cookie = claimsHelper.CookieContainer;  
  6.   
  7. string cookieHeader = cookie.GetCookieHeader(new Uri("https://ybbest.sharepoint.com/"));  
  8. p.Headers.Add("Cookie", cookieHeader);  
  9. using (ListsSoapClient proxy = new ListsSoapClient())  
  10. {  
  11. proxy.Endpoint.Address = new EndpointAddress("https://ybbest.sharepoint.com/_vti_bin/Lists.asmx");  
  12.   
  13. using (new OperationContextScope(proxy.InnerChannel))  
  14. {  
  15. OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = p;  
  16. XElement spLists = proxy.GetListCollection();  
  17. foreach (var el in spLists.Descendants())  
  18. {  
  19. //System.Console.WriteLine(el.Name);  
  20. foreach (var attrib in el.Attributes())  
  21. {  
  22. if (attrib.Name.LocalName.ToLower() == "title")  
  23. {  
  24. System.Console.WriteLine("> " + attrib.Name + " = " + attrib.Value);  
  25. }  
  26. }  
  27. }  
  28. }  
  29. System.Console.ReadKey();  
  30. }  
  31. }  

In my previous post, I showed you how to call the SharePoint web service using a console application. In this post, I’d like to show you how to call the same web service in the cloud, aka Office365.In office365, it uses claims authentication as opposed to windows authentication for normal in-house SharePoint Deployment. For Details of the explanation you can see Wictor’s post on this here. The key to make it work is to understand when you authenticate from Office365, you get your authentication token. You then need to pass this token to your HTTP request as cookie to make the web service call. Here is the code sample to make it work.I have modified Wictor’s by removing the client object references.

You can download the complete code from here.
Reference: