I'm trying to find a way using the Office.Interop.Outlook COM object to connect to an additional Mailbox. Currently I am doing the following (after adding the COM object):
var app = new Microsoft.Office.Interop.Outlook.Application();
var ns = app.GetNamespace("MAPI");
ns.Logon();
var inboxFolder = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
This successfully connects me to my main Inbox which I can then loop through.
What I am trying to find next is a way to use additional Mailbox X and get the default folder.
I am using Framework 4.0 with the COM object Microsoft Outlook 12.0 Object Library (version 9.3)
Not sure on the version of Exchange.
Cheers
I think I have it :-
ns = app.GetNamespace("MAPI");
ns.Logon();
var recipient = ns.CreateRecipient("xx#yy.com");
recipient.Resolve();
var sharedFolder = ns.GetSharedDefaultFolder(recipient, Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
Not sure if the ns.Logon is necessary, but I have left it anyway.
Luke has the correct answer above. The following code works for Python 3.7 using pywin32:
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
other_user = outlook.CreateRecipient("user.name#example.com")
print(other_user)
other_mailbox = outlook.GetSharedDefaultFolder(other_user, 6) # 6= inbox see https://learn.microsoft.com/en-us/dotnet/api/microsoft.office.interop.outlook.oldefaultfolders?view=outlook-pia
print(other_mailbox)
print(other_mailbox.Items[0])
Related
I need to launch outlook calendar appointment in bot application. I found the below code in Microsoft documentation for launching outlook email.
var message = context.MakeMessage() as IMessageActivity;
message.ChannelData = JObject.FromObject(new
{
action = new { type = "LaunchUri", uri = "mailto:someone#example.comsubject=This%20is%20the%20subject&body=This%20is%20t e%20body"
}
});
await context.PostAsync(message);
And also i tried the Microsoft.Office.Interop.Outlook to add appointment , it also doesn't work for me.
Outlook.Application outlookApp = new Outlook.Application(); // creates new outlook app
Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem)outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem); // creates a new appointment
oAppointment.Subject = apt.Subject;
oAppointment.Body = apt.Body;
oAppointment.Location = apt.Location;
oAppointment.Start = Convert.ToDateTime(apt.StartTime);
oAppointment.End = Convert.ToDateTime(apt.EndTime);
Is there any better way to launch outlook calendar appointment.
Your code must call oAppointment.Save.
What exactly are you trying to do? Silently create an appointment (then you code above needs to call oAppointment.Save) or display it to the user (then call oAppointment.Display)?
If your code is running on a server, create an iCal file and let the user download and open in (local) Outlook - it will be happy to display the appointment.
Steve mentioned you could use Microsoft Graph.
You might be able to send an ics file as a media attachment (I haven't tried).
Or you can investigate if the protocol handler outlookcal: supports deep linking.
I think this link tells you how it works in Teams
https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/deep-links
I am using crm 2016 and I need to clone a record using plugin, after googling I found out that I need to use Microsoft.Xrm.Client that hold the clone() function - which is not in 2016 SDK because of MS reorganization.This lib is in 2015 SDK.
My questions are :
1. If I'll take that lib from CRM 2015 and use it in 2016 will it be supported?
2. If it's not supported what are my options to clone a record in server side?
The method Clone() in the Microsoft.Xrm.Client only creates a copy of the Entity object in memory. It does not create a copy in the database of CRM. When you need to create a copy in the database just instantiate a new Entity object and pass it to the Create() method of the IOrganizationService interface.
When you really need a deep clone as described on MSDN you could consider writing one yourself. In most scenarios you will only need to copy the objects in the attributes collection. Of those objects only the reference types EntityReference, OptionSetValue and Money wiil need your special attention.
I would not advise to use deprecated libraries.
We use the following helper method to clone an entity - this is an updated version from the original which correctly clones the reference types, and excludes the system attributes
public static Entity CloneEntitySandbox(Entity entityToClone)
{
var newEntity = new Entity(entityToClone.LogicalName);
var systemAttributes = new List<string>();
systemAttributes.Add("createdon");
systemAttributes.Add("createdby");
systemAttributes.Add("modifiedon");
systemAttributes.Add("modifiedby");
systemAttributes.Add("owninguser");
systemAttributes.Add("owningbusinessunit");
foreach (var attribute in entityToClone.Attributes
.Where(x => x.Key != entityToClone.LogicalName + "id")
.Where(x => !systemAttributes.Contains(x.Key)))
{
switch (attribute.Value.GetType().Name)
{
case "Money":
var m = attribute.Value as Money;
newEntity[attribute.Key] = new Money(m.Value);
break;
case "EntityReference":
var er = attribute.Value as EntityReference;
newEntity[attribute.Key] = new EntityReference(er.LogicalName, er.Id);
break;
case "OptionSetValue":
var os = attribute.Value as OptionSetValue;
newEntity[attribute.Key] = new OptionSetValue(os.Value);
break;
default:
newEntity[attribute.Key] = attribute.Value;
break;
}
}
return newEntity;
}
Note that this does not perform the save to create the cloned entity in the CRM database, that's up to you.
Microsoft announcement says:
We also removed Microsoft.Xrm.Client from the CRM 2016 (8.x) SDK client because it was not compliant with the OAuth changes, and replaced it with Microsoft.Xrm.Tooling.Connector. You can use the current Microsoft Dynamics 365 Software Development Kit (SDK) to access Microsoft Dynamics CRM back to version 6.x for both auth and messaging.
Dynamics 365 SDK Backwards Compatibility
You can still use Microsoft.Xrm.Client.dll in your project from older SDK, this maybe supported for a while.
But I would recommend to go with custom Action, taking parent record as EntityReference Input parameter, Retrieve the parent record data + needed related entities & manually create (clone) child record + related entities records in Action.
You can Execute/invoke this Action from client/server side, wherever you want.
I would like to write a mozilla firefox extension by using the WebExtension API. I couldn´t find a source code using the WebExtension API for my purposes.
var {Cc, Ci} = require("chrome"); // Low-Level API Imports (For Launcher)
var prefs = require("sdk/simple-prefs").prefs;
var app = "C:\\abcd\\test.exe";
var file = Cc["#mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
file.initWithPath(app);
var process = Cc["#mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
if (file.exists()) {
process.init(file);
var params = prefs["param"];
var args = ["" + params + ""];
process.run(false, args, args.length);
}
How does a source code for writing a mozilla firefox extension by using the WebExtension API look like?
Unfortunately I can´t use your suggested solution, because there have to be made settings on the local PC additional to the Addon. I would like to prevent making these settings. I am interested in a solution, where a variable path can be executed directly out of the Browser. For example, a folder or a local file should open there
can't be done with webextensions alone (webextensions were in part meant to prevent this), you'd have to have a native app installed as well, and message pass to it, using the native messaging api that was mentioned.
We are implementing a server for app distribution and we need restrict the access to the apps by:
mac address
ip
At the moment I have not found any module that can obtain this data from the device in nativescript, so i don't know if there's a plugin or how else can I achieve this.
In nativescript you can access native apis of device
so if there isn't any module/plugin for it you can use this option for accessing native apis.
https://docs.nativescript.org/core-concepts/accessing-native-apis-with-javascript
for example there is solution for mac adress here
in JAVA:
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wInfo = wifiManager.getConnectionInfo();
String mac = wInfo.getMacAddress();
we can write it in javascript like this:
first we should fine where is this getSystemService:
after searching in documentation of android we found:
getSystemService is in android.content.Context
for accessing context in nativescript http://docs.nativescript.org/cookbook/application
we can do:
import app = require("application");
app.android.context;
so let's write it in javascript:
we don't have types in javascript so we use var instead;
var context = android.content.Context;
var wifiManager = app.android.context.getSystemService(context.WIFI_SERVICE);
var wInfo = wifiManager.getConnectionInfo();
var mac = wInfo.getMacAddress();
NOTE1 : as mentioned in above java solution link you should add this permision <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission> to app/App_Resources/AndroidManifest
NOTE2 : the above solution was for android,for ios you should find the solution with objective_c and convert to javascript with help of nativescript documentation.
NOTE3:In android 6 you might need request permision
You can also use this method to create a plugin for nativescript.
I am trying to use the Google Calendar API in .NET, specifically I am trying to get a list of events. According to the examples here, in different programming languages I need to create a 'service' object and an 'event' object. However, I can't find a clear explanation of what either of these objects is or how to initiate them. Does anyone have an explanation? Or can anyone provide any information or give me a link to where this is explained? It doesn't necessarily have to be in .NET
Here is the example in Java:
String pageToken = null;
do {
events = service.events().list('primary').setPageToken(pageToken).execute();
List<Event> items = events.getItems();
for (Event event : items) {
System.out.println(event.getSummary());
}
pageToken = events.getNextPageToken();
} while (pageToken != null);
Following the advice answered, I am getting the following error:
Could not load file or assembly 'Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.16.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Here is the code, the error occurs on the credentials = Await... line
Dim credential As UserCredential
Dim clientSecretsPath As String = Server.MapPath("~/App_Data/client_secret.json")
Dim scopes As IList(Of String) = New List(Of String)()
scopes.Add(CalendarService.Scope.Calendar)
Using stream = New System.IO.FileStream(clientSecretsPath, System.IO.FileMode.Open, System.IO.FileAccess.Read)
credential = Await GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, scopes, "user", CancellationToken.None)
End Using
The problem with GoogleWebAuthorizationBroker is that it tries to launch a new instance of a web browser to go and get authorization where you have to click the "Grant" button.
Obviously if you're running a MVC project under IIS it's just going to get confused when the code tries to execute a web browser!
My solution:
Download the .net sample projects: https://code.google.com/p/google-api-dotnet-client/source/checkout?repo=samples
Build and run one of the projects relevant to you (Eg Calendar or Drive). Dont forget to include your client_secret.json file downloaded from the cloud console.
Run the project and it will open a new browser on your computer where you will have to click the "Grant" button. Do this once and then your MVC code will work because it will not try to open a web browser to grant the permissions.
I'm not aware of any other way to grant this permission to the SDK but it worked for me just great!
Good luck. This took me a good 5 hours to figure out.
Just had the same issue running VS2013 (using .net45 for my project):
After fetching the CalendarV3 API via NuGet you just have to manually add the reference to:
...packages\Microsoft.Bcl.Async.1.0.165\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll
to the project (because it is not inserted automatically via the NuGet-Script)!
That's it! Maybe #peleyal is correcting the script somewhen in future ;)
Remember that this sample is for Java. My recommendation is to do the following:
Take a look in our VB sample for the Calendar API which is available here
You should take a look also in other sample for C#, let's say Tasks API sample
Start a new project and add a NuGet reference to Google.Apis.Calednar.v3. Remember that it's prerelease version.
Your code should look like the following:
It's based on the 2 samples above, I didn't compile or test it but it should work.
UserCredential credential;
using (var stream = new System.IO.FileStream("client_secrets.json",
System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { CalendarService.Scope.Calendar },
"user", CancellationToken.None);
}
// Create the service.
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "YOUR APP NAME HERE",
});
var firstCalendar = (await service.CalendarList.List().ExecuteAsync()).Items().FirstOrDefault();
if (firstCalendar != null)
{
// Get all events from the first calendar.
var calEvents = await service.Events.List(firstCalendar.Id).ExecuteAsync();
// DO SOMETHING
var nextPage = calEvents.NextPage;
while (nextPage != null)
{
var listRequest = service.Events.List(firstCalendar.Id);
// Set the page token for getting the next events.
listRequest.PageToken = nextPage;
calEvents = await listRequest.EsecuteAsync();
// DO SOMETHING
nextPage = calEvents.NextPage;
}
}
I had the same error, and it was due to the app trying to launch the accept screen.
I first tried to get the vb.net example from google and ran that, which I did get to work, and change to my secret info, ran and got the accept screen. I then tried my app, and it still did not work.
I noticed that the dll was found here under my project installed from the nuget packages.
...packages\Microsoft.Bcl.Async.1.0.165\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll
but was not in the net45 dir. So I uninstalled the nuget packages (have to if changing the .net version) then changed my .net version for my project to 4.0 instead of 4.5, reinstalled the nuget packages, and then it worked!!