I am trying to establish a connection with Exchange 2013 to retrieve a list of Contacts (from Global Contacts) given a certain criteria. This code works from a test console application, but when I place it in an Outlook Add-In, then it fails to even execute the method that contains the connection code, without throwing any exception. This is an extract of the code:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
service.UseDefaultCredentials = true;
service.AutodiscoverUrl(emailAccount, RedirectionUrlValidationCallback);
NameResolutionCollection coll = service.ResolveName(searchStr, ResolveNameSearchLocation.DirectoryThenContacts, true);
Anybody has any idea why is this happening? Or if there is another way to search for Global Contacts in Exchange 2013 from an Add-In?
Related
We have a VSTO add-in for Outlook, that supports booking of resources managed by our cloud system.
In addition we support resources that are also available in Exchange as rooms to support integration with other systems.
When we perform a booking of such a room, the add-in adds the corresponding Exchange email address for the room to recipients, so it will also be booked in Exchange.
This used to work fine, but now we have received a report from a customer that they can no longer create bookings for resources with Exchange integration. The error they receive is completely unhelpful:
System.ArgumentException: Der gik desværre noget galt. Du kan prøve igen.
ved Microsoft.Office.Interop.Outlook._AppointmentItem.Save()
(in English: "Something went wrong. You can try again")
This happens when add-in attempts to save the item after adding some custom properties. I think the error is triggered by the add-in adding the Exchange rooms to recipients, since it does not happen for resources without Exchange integration.
Here is the code we use to add recipients:
var rec = ...; // custom DTO with recipient info
string recipientInfo = string.IsNullOrEmpty(rec.Email)
? rec.OutlookName
: rec.Email;
var recRecip = appointment.Recipients.Add(recipientInfo);
recRecip.Type = rec.RecipientType;
if (Current.Settings.IsEnabled(FeatureFlag.ResolveAddedRecipients))
{
using (LogHelper.TimedTask($"resolving recipient [{rec}]", Log))
{
recRecip.Resolve();
}
}
I can see from the logs, that the room recipient has email address, so above code will add by email. Also, the feature flag to resolve recipients is enabled, so the code will call resolve afterwards.
What could be going wrong here?
EDIT: Their Outlook version is 16.0.0.5071.
If the problem is isolated to the user's computer, we always recommend our IT staff to share the O365 Outlook Diagnostics Tool which analyses the outlook install, data files, plugins, cache and performs checks to identify source of issues on client computers.
yesterday I created a new installation of Microsoft CRM Online.
Now I'm trying to access the webservice using the sdk provided from Microsoft.
When i try to connect to Microsoft CRM Online I get this error:
An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
I read in some posts that it can be the hours difference between my machine and the CRM Online Server, but I've tried running this code unsuccessfully using all the hours.
CrmConnection crmConnection = CrmConnection.Parse("Url=https://desenvolvimento.crm2.dynamics.com/XRMServices/2011/Organization.svc; Username=jones.rives#desenvolvimento.onmicrosoft.com; Password=XXX;");
OrganizationService service = new OrganizationService(crmConnection);
Entity account = new Entity("account");
account["name"] = "Test Account";
account.Id = Guid.NewGuid();
Guid accountId = service.Create(account);
Is it different to connect to CRM Online using 365 credentials? I really can't find the problem, and I've tried many solutions, but none worked.
Thanks in advise.
You don't need to put the endpoint inside the connection string when you use the simplified connection, just the organization url.
Assuming your url is correct (meaning you can login using a browser), try with:
CrmConnection crmConnection = CrmConnection.Parse("Url=https://desenvolvimento.crm2.dynamics.com; Username=jones.rives#desenvolvimento.onmicrosoft.com; Password=XXX;");
OrganizationService service = new OrganizationService(crmConnection);
Entity account = new Entity("account");
account["name"] = "Test Account";
Guid accountId = service.Create(account);
Currently I'm working on a task to fix the process of opening custom web page in outlook client from custom ribbon button, it's similar to this question:
JavaScript pop-up in Dynamics CRM 2011 Outlook client
client
However, I have configured the website to have the same authentication token from the same ADFS as CRM web. If I open it using IE/any other web browsers (in UR 12), it works fine. If I open it using outlook client, it keep prompting the user to authenticate (which is quite annoying for some users).
I've read these, but they are only applicable for CRM form, not custom web app:
ADFS (CRM 2011) - Authentication Issue in Microsoft Outlook Client for CRM (Response.Redirect(...) & Window.Open(...))
http://msdn.microsoft.com/en-us/library/jj602956.aspx
Anyone have any idea on this?
FYI, I'm using CRM 2011 UR 12, and Outlook 2010 with CRM client.
TIA
I ended-up using openStdWin, based on: http://blog.customereffective.com/blog/2011/12/jscript-pop-up-in-crm-402011-internet-explorer-vs-outlook.html and Dieter's comment. It still asked me to authenticate once, even though I've provided the login detail in outlook client setup.
The javascript function:
function openNewWindow(url) {
var name = "newWindow";
var width = 800;
var height = 600;
var newWindowFeatures = "status=1";
var oldWindowFeatures = "width=800,height=600,status=1";
// Regular Jscript function to open a new window
//window.open(url, name, oldWindowFeatures);
// CRM function to open a new window
openStdWin(url, name, width, height, newWindowFeatures);
// CRM function to open a new window
// with default CRM parameters
//openStdWin(url, name);
}
We are developing a module with the main goal being to track and collect information about damage inspections (insurance market). Each case has a code (e.g. L000525). Each case could be managed by several people. All the emails related to a specific case include the case code in the subject.
What we want to do is to collect and show the incoming and sent emails related to each specific case.
The idea is that any user can open a "Case management" window, select an specific case, and then get all the related information (including the emails of course).
We have to find the emails into the the mailboxes of around 20 users. So the questions are:
Which is the better way to do this? Will it consume a lot of time and resources?
We are new in the Exchange world so we are thinking Exchange impersonation, but we are not sure at all. The module is developed in Silverlight 3, WCF, SQL Server + Exchange 2007.
If the credentials used to connect to EWS have rights to access a user's mailbox then you should be able to do something like this:
var service = new ExchangeService();
service.Credentials = new WebCredentials("user_with_access#example.com", "password");
service.AutodiscoverUrl("a_valid_user#example.com");
var userMailbox = new Mailbox("target_user#example.com");
var folderId = new FolderId(WellKnownFolderName.Inbox, userMailbox);
var itemView = new ItemView(20); // page size
var userItems = service.FindItems(folderId, itemView);
foreach (var item in userItems)
{
// do something with item (nb: it might not be a message)
}
That's it. Wow, my first SO answer!
A full working example of what #smcintosh has done above is here: Office365 API - Admin accessing another users/room's calendar events. It is a full java class that should compile and run and accesses a room resource calendar. Good luck!
I am trying to send an outlook appointment through code. My code is posted below. When I run it on the server with IIS 6 and an app pool under a domain account identity, it throws this error. I have tried changing various settings on the server and none worked. Outlook 2007 is installed. I have even made the domain account a local admin. Please help!
Description: An unhandled exception
occurred during the execution of the
current web request. Please review the
stack trace for more information about
the error and where it originated in
the code.
Exception Details:
System.Runtime.InteropServices.COMException:
Operation aborted (Exception from
HRESULT: 0x80004004 (E_ABORT))
Line 201: objAppt.Send();
Code below:
Microsoft.Office.Interop.Outlook.Application objOL
= new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.AppointmentItem objAppt
= (Microsoft.Office.Interop.Outlook.AppointmentItem)objOL
.CreateItem
(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
objAppt.Start = startTime;//datetime
objAppt.End = endTime;//datetime
objAppt.Subject = subject;
objAppt.Body = body;
objAppt.Location = location;
objAppt.MeetingStatus
= Microsoft.Office.Interop.Outlook.OlMeetingStatus.olMeeting;
objAppt.RequiredAttendees = "test#test.com";
objAppt.Send();
objAppt = null;
objOL = null;
Yes as casperOne said I wouldn't use outlook on the server. I would use CDO or RDO(redemeption) for this. or even use vcal and send the vcal on a system.Net.Mail.
Update:
Take a look at http://www.dimastr.com/redemption/rdo/RDOAppointmenItem.htm
Show you how to do excatly what you want to do using RDO. You can do the same with CDO as well. Check out CDOLive.com
You will have to construct a teh login details as you are on a server that has no Outlook profile (thats if you remove the one that you allready have on there)
Quite simply, you shouldn't be doing this. It is not recommended that you run Office in a server environment because of the threading (and desktop session) requirements that Office has.
Are you trying to do this on an Exchange server? If so, then I would interact directly with the Exchange server (using WebDAV perhaps?).
If not connecting with Exchange, then take a look at the headers for an invitation to the event. The invitations should be nothing more than regular emails with custom header information.
I guess the reason you cannot use Outlook from an IIS application is because the current user the IIS app is running under does not have an Outlook profile associated.
Therefore you can instantiate Outlook objects and set their properties, until profile-specific functionality is required, such as the Send() command, which would store the outgoing mail in the user's/profile's (non-existing) pst file.
Don't do this using Outlook automation.
Straight from the horse's mouth:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.
http://support.microsoft.com/kb/257757
Examine email headers sent by Outlook when it's doing this job to work out how this is done, and emulate it using the standard .NET SmtpClient stuff.