I created a custom ribbon for Microsoft Outlook and I have a button called view profile. I want to be able to bring up the Contact Card Viewer/Editor for the current user. I created a call back and I think I have the general idea of how to get his done but I am having trouble making the connection once I find the current user to getting it to open for that user. Here is the code I have so far for the call back.
public void button2_Click(Office.IRibbonControl control)
{
var appOutlook = new Microsoft.Office.Interop.Outlook.Application();
Outlook.ExchangeUser currentUser = appOutlook.Session.CurrentUser.AddressEntry.GetExchangeUser();
ContactItem contactinfo = currentUser;
contactinfo.ShowBusinessCardEditor();
}
You can use the ContactCard.
Here is C# code converted from the VBA example on this page https://msdn.microsoft.com/en-us/library/office/ff869218.aspx
var session = appOutlook.Session;
var adr = session.CurrentUser.AddressEntry;
var cc = session.CreateContactCard(adr);
cc.Show(MsoContactCardStyle.msoContactCardFull, 100, 100, 100, 100, 100, true);
The easiest way is just calling the .Display(modal: true / false) method on the ContactItem.
ContactItem contact = ...
contact.Display(true); // for modal
Simply call AddressEntry.Details:
Outlook.AddressEntry currentUser = appOutlook.Session.CurrentUser.AddressEntry;
currentUser.Details();
Related
I am creating the login part of a Xamarin.iOS application. When logging in I want to pass an User Object to the ProjectsViewController. First a user enters the username and password, then it is validated and lastly, once it is validated I want to go to the main screen which is called ProjectsViewController.
//first get user from Restful service
var response = await apiService.GetUserByToken("http://192.168.1.20:55405",
"/api",
"/Account/FullUser",
token.TokenType,
token.AccessToken);
//get User object
var user = (User)response.Result;
user.Password = password;
if (response.IsSuccess)
{
//loguser is the User object that will be passed to the root
logUser = user;
}
//get storyboard
UIStoryboard board = UIStoryboard.FromName("Main", null);
ProjectsViewController ctrl = (ProjectsViewController)board.InstantiateViewController("projectsViewController");
//current user is the propery that I want to access in the next screen
ctrl.CurrentUser = logUser;
ctrl.ModalTransitionStyle = UIModalTransitionStyle.CoverVertical;
UINavigationController nav = (UINavigationController)board.InstantiateViewController("navController");
nav.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve;
//this sends me to the root but the object is not passed
PresentViewController(nav, true, null);
The code so far validates the user and sends me to the root screen, but the object is not passed. Please help!
thanks in advance!
The thing is that you are creating a new instance of the: ProjectsViewController and setting its CurrentUser, but you are not showing that controller at all.
What you should do is:
UINavigationController nav = (UINavigationController)board.InstantiateViewController("navController");
nav.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve;
//New code
var projectVC = (ProjectsViewController)nav.ViewControllers.FirstOrDefault();
projectVC.CurrentUser = logUser;
PresentViewController(nav, true, null);
Since when you instantiate the: "navController" from storyboard it will also instantiate its ProjectsViewController, which is in its ViewControllers list.
I am trying to have my application to open the Outlook meeting window with some pre-populated fields.
I have found that this question was already asked here.
However, the code provided in the answer(which works fine) doesn't open the meeting window but the appointement window. Those are two different things that are handled differently in Outlook and what I need is indeed the meeting window.
Is there any way to achieve this or do I absolutely have to open the appointement window first and then invite people to turn it into a meeting?
Create an appointment just as in the other question, but then set the MeetingStatus property of the appointment.
Microsoft.Office.Interop.Outlook.Application outlookApplication = new Microsoft.Office.Interop.Outlook.Application(); ;
Microsoft.Office.Interop.Outlook.AppointmentItem appointmentItem = (Microsoft.Office.Interop.Outlook.AppointmentItem)outlookApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
// This line was added
appointmentItem.MeetingStatus = Microsoft.Office.Interop.Outlook.OlMeetingStatus.olMeeting;
appointmentItem.Subject = "Meeting Subject";
appointmentItem.Body = "The body of the meeting";
appointmentItem.Location = "Room #1";
appointmentItem.Start = DateTime.Now;
appointmentItem.Recipients.Add("test#test.com");
appointmentItem.End = DateTime.Now.AddHours(1);
appointmentItem.ReminderSet = true;
appointmentItem.ReminderMinutesBeforeStart = 15;
appointmentItem.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;
appointmentItem.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;
appointmentItem.Recipients.ResolveAll();
appointmentItem.Display(true);
One more note to NineBerries good solution, because I had an issue here:
The line
appointmentItem.Recipients.ResolveAll();
is necessary if you have optional attendees in the meeting.
Otherwise they will be reset to "required" even if you set
recipient.Type = Microsoft.Office.Interop.Outlook.OlMeetingRecipientType.olOptional;
before, which is due to "late auto-resolving" of names in Outlook (or so it seems).
I am trying to add appointments to Outlook programmatically.
I ran this code which runs successful but after I save the appointment the meeting editor opens up in outlook.
AppointmentItem appItem = null;
try
{
appItem = outlookItems.Add(OlItemType.olAppointmentItem) as AppointmentItem;
if(appItem == null)
continue;
appItem.Subject = "Subject";
appItem.MeetingStatus = OlMeetingStatus.olMeeting;
appItem.Location = "Location";
appItem.Save();
appItem.Display(true);
}
finally
{
if (appItem != null)
{
Marshal.ReleaseComObject(appItem);
}
}
I tried calling Display(true), Display(false) it still doesn't work.
Please can anyone tell me if I am doing anything wrong.
But you create a new meeting item in the code setting the following property:
appItem.MeetingStatus = OlMeetingStatus.olMeeting;
If you don't want to see a new item window (inspector), there is no need to run the following line of code:
appItem.Display(true);
The Display method displays a new Inspector object for the item.
You may find the Getting Started with VBA in Outlook 2010 article in MSDN helpful.
if the appointment is of type OlMeetingStatus.olMeeting, recipients are supposed to be present.
I changed the type to
appItem.MeetingStatus = OlMeetingStatus.olNonMeeting
and removed the call to display. I was able to save the appointment in the calendar
My Requirement: I want to know which page I am currently in so that if any test fails I want to pass the current page's URL to a method and get the home button link. Ultimately navigating to the home link in case of any exception.
Is there a way to achieve it ?
The URL should be in the address bar of the browser, just read it out of there.
One way of reading out the value is to record an assertion on the value in the address bar, then copy the part of the code in the recorded assertion method that accesses the value.
Another way is to use the cross-hairs tool to select the address area, then (click the double-chevron icon to open the left hand pane and) add the UI control for the selected area. Then access the value.
This will return the top Browser:
BrowserWindow bw = null;
try
{
Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.AllThreads;
var browser = new BrowserWindow() /*{ TechnologyName = "MSAA" }*/;
PropertyExpressionCollection f = new PropertyExpressionCollection();
f.Add("TechnologyName", "MSAA");
f.Add("ClassName", "IEFrame");
f.Add("ControlType", "Window");
browser.SearchProperties.AddRange(f);
UITestControlCollection coll = browser.FindMatchingControls();
// get top of browser stack
foreach (BrowserWindow win in coll)
{
bw = win;
break;
}
String url = bw.Uri.ToString(); //this is the value you want to save
}
catch (Exception e)
{
throw new Exception("Exception getting active (top) browser: - ------" + e.Message);
}
finally
{
Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.UIThreadOnly;
}
We are working on implementing some custom code on a workflow in a Sitecore 6.2 site. Our workflow currently looks something like the following:
Our goal is simple: email the submitter whether their content revision was approved or rejected in the "Awaiting Approval" step along with the comments that the reviewer made. To accomplish this we are adding an action under the "Approve" and "Reject" steps like so:
We are having two big issues in trying to write this code
There doesn't seem to be any easy way to determine which Command was chosen (the workaround would be to pass an argument in the action step but I'd much rather detect which was chosen)
I can't seem to get the comments within this workflow state (I can get them is the next state though)
For further context, here is the code that I have so far:
var contentItem = args.DataItem;
var contentDatabase = contentItem.Database;
var contentWorkflow = contentDatabase.WorkflowProvider.GetWorkflow(contentItem);
var contentHistory = contentWorkflow.GetHistory(contentItem);
//Get the workflow history so that we can email the last person in that chain.
if (contentHistory.Length > 0)
{
//contentWorkflow.GetCommands
var status = contentWorkflow.GetState(contentHistory[contentHistory.Length - 1].NewState);
//submitting user (string)
string lastUser = contentHistory[contentHistory.Length - 1].User;
//approve/reject comments
var message = contentHistory[contentHistory.Length - 1].Text;
//sitecore user (so we can get email address)
var submittingUser = sc.Security.Accounts.User.FromName(lastUser, false);
}
I ended up with the following code. I still see no good way to differentiate between commands but have instead implemented two separate classes (one for approve, one for reject):
public void Process(WorkflowPipelineArgs args)
{
//all variables get initialized
string contentPath = args.DataItem.Paths.ContentPath;
var contentItem = args.DataItem;
var contentWorkflow = contentItem.Database.WorkflowProvider.GetWorkflow(contentItem);
var contentHistory = contentWorkflow.GetHistory(contentItem);
var status = "Approved";
var subject = "Item approved in workflow: ";
var message = "The above item was approved in workflow.";
var comments = args.Comments;
//Get the workflow history so that we can email the last person in that chain.
if (contentHistory.Length > 0)
{
//submitting user (string)
string lastUser = contentHistory[contentHistory.Length - 1].User;
var submittingUser = Sitecore.Security.Accounts.User.FromName(lastUser, false);
//send email however you like (we use postmark, for example)
//submittingUser.Profile.Email
}
}
I have answered a very similar question.
Basically you need to get the Mail Workflow Action and then you need to further extend it to use the original's submitter's email.
Easiest way to get the command item itself is ProcessorItem.InnerItem.Parent
This will give you the GUID for commands like submit, reject etc.
args.CommandItem.ID
This will give you the GUID for states like Draft, approved etc.
args.CommandItem.ParentID