Microsoft Graph - Building commercial applications - Authentication? - c#

** Edit - Based on further questoins **
I'm writing a c# application, that uses ConfidentialClientApplication. I have set up the application in azure and can connect and get a token.
The software will in fact, reside on a server, it will look something like this:
A backend process will query the mailbox and get either a) A list of messages or b) the first message available
It will download hte message and strip any attachments for further processing
Once the processing is complete, it will need to move the mail to a folder, so that it is not processed again
I want to be able to pass the application, the mailbox name and the password to connect to it, a bit like POP3/IMAP. So far, I can get a token, but anything beyond that, just barks that it doesnt have access, quite rightly.
So how do I take this one step further, and either:
Grant the application access to a specific mailbox using azure portal
or
Configure the application to read the mailbox from a settings file and connect to it?
Many thanks!
Tirm

Related

Direction on how to run PowerShell script to create email box on Exchange server

Here's what I'm trying to accomplish: users have a need to create an email address through a web app (basically, it uses existing information to create custom, unique email addresses). Currently, the web app just generates the name, then they turn it over to us, and we run a PS script on Exchange to create the box. I'd like the box to be created when they request an email on the web app. There's probably like 10 ways to do this, but I'm thinking it would be a webservice that passes the email name to a Windows app on Exchange that executes the script and returns Success/Failure/Etc.. Does this seem viable. I'm not sure how to thread the process of running the PS script. Does anyone have any thoughts? I'm not looking for someone to write the code, but perhaps have some architectural ideas.
There are several methods but the "easiest" one that pops into my head is as follows:
User logs into create-an-address web app
They submit a request into the app which stores the data in a SQL table (if exists)
STSS/DTS package produces a CSV output of date+ new entries and drops it into a Temp directory
Or skip the database and create/append a daily CSV-formatted file direct from the web app.
Scheduled job runs the powershell script which parses the CSV via for-each and creates users & mailboxes as needed. If user exists, only add smtp to existing mailbox or whatever your requirements are
Powershell deletes the file if success or moves to another folder for investigation if failure occurs.
We've done similar data ingestions for various applications and it works well. We add email events into the script for success/failures but we like the database approach because can ingest the CSV status with other STSS packages for historical reporting

Save an Exchange mailitem to the filesystem local to the Exchange Server using EWS?

It's my first question/post :-/
Background to question:-
I have an ongoing project which is an Azure hosted ASP.NET solution. Its a generic ERP and is intended for small enterprise businesses. An additional requirement came up and I'd like it to be part of the Azure solution (previous attempt to create a VSTO add-in went bad).
I've been asked to automate this process:- Users spend a long time (daily basis) manually saving emails into network shared directories according to what company project the emails relate to. E.g. everytime Sally sends or receives an email, she copies and renames the .msg file from outlook into her "G:/" drive (which is just a network share on the enterprise LAN). Someone else in the enterprise has the job of creating a specific directory structure for sally (and her co-workers) to save the emails in (e.g. Correspondance-In, Correspondance-Out etc..). Staff need to be able to search the directories for messages based on some scraped meta data.
I'm considering an exchange web service managed API application in Azure which has a service that polls the Exchange Server (for every user) with a pull subscription to identify new/changed mails. Each identified mail will be then assessed against a rule that the user has pre registered in my application (i.e. from person x with project ID in the subject field). The application will then rename the email and put it in the network share (also scrape metadata to provide search functionality).
Question:-
a) How do I get my remote application to request the Exchange Server or CAS to export the MailItem to a local network share using exchange web services in the most efficient way? Preferably without having to deploy something into the enterprise.
b) is this a ridiculous solution?
Additional Info:
I expect the typical environment to be quite old. However, I can assume Exchange Server 2007+ and Outlook Clients 2007+ on Win7 (no Office365 though and no sharepoint). I decided to use a pull subscription as it will be a loosely coupled environment and therefore assumed streaming to be not the best fit.
MailItems are likely to contain large attachments (CAD drawings etc) so for obvious reasons, I would like to avoid pulling these across the WAN.
I have investigated the potential to create server side mailbox rules with EWS therefore allowing this exchange server to manage the export - however if I understand correctly, rules don't support exporting MailItems to the filesystem.

Keeping track of outgoing emails from any .NET application

I have windows 2003 server with about 15 C# windows services sending emails randomly based on some complex business logic. It is a very difficult to find out which application sending emails to whom at what time.
For additional info, the server has McAfee client installed and configured by admin that which application can send emails.
Is there any way I can find out which application is sending email to whom?
If you can't store the information required in a database, then generate log files specific to your need. I'm certain you don't need code to tell you how to have your C# services generate log files that contain all the pertinent information (date/time, service name, email address, type/id or some content identifier). You can then use the logs to generate whatever reporting you need, and if build with configuration, you can turn off the logging once you have enough information to answer the question.

Get Windows logged in user's email when offline

We use this code to get the email of the currently logged in user:
var currentUsersEmail = UserPrincipal.Current.EmailAddress;
This works fine when on the network. However, we have laptop users who run our code remotely and in a disconnected state. The above code causes this exception when in this state:
System.DirectoryServices.AccountManagement.PrincipalServerDownException
Message: "The server could not be contacted."
Does anyone know a way to retrive the current user's email that will work both when connected / on the network and when disconnected?
UPDATE: In case you are wondering why we want to do this. Our system has a bunch of methods that send alerts via email. When our developers are running automated tests, we want the emails to be sent to the current logged in user (i.e. the developer) so they can verify the format.
You could rewrite your application so that it uses UserPrincipal.Current.EmailAddress the first time, and perhaps whenever it is online, and then saves that information in the user's AppData folder or registry for reference when working offline. It would require running the application at least one online before working offline, but I don't see how else you could do it without having to ask the user or use a config file.
There is simply no way the System.DirectoryServices.AccountManagement namespace will work offline. It's like asking how can a database driven application work without access to the database.

Skype plugin in C#

I write system, that collects informations about local system. It's a system like admin-client. Client collects and sends log to admin. There's of course possibility to get this log by admin over LAN, but I'd like to add option send log over Internet.
I thought about skype. Client must have logged skype and when admin (of course there must be appropriate authorization, but it's separate topic) send request by skype - client must e.g. connect to SQL database or simple file with collected log and send it over skype.
How can I do this?
Is this the best way? Plugin in skype? What lib may I use?
I think it's an either/or situation.
If you want an administrator who is already using Skype to be able to send this information over the internet, then a plugin which exposes that functionality in Skype is the way to go.
If you want the administrator to be able to send the information over Skype's network, but not necessarily have to have the application running (perhaps this will be done through the application that gathers data), then using the API to control Skype externally is better.
You can find the documentation for Skype here:
http://developer.skype.com/accessories
Skype has a COM API called Skype4COM which you could use through COM interop in order to access Skype.
It should be noted that SkypeKit is now available for use in both embedded and desktop programs. There's a small one-time registration fee (currently $5 USD) for each program, but it will allow you to access Skype without actually using any UI functionality (it's completely up to you to provide the interface).
Until SkypeKit is released, you're limited to the Skype Public API. However according to the docs this API only allows to specify the recipient and open the file dialog, initiating a file transfer automatically seems to be impossible (see "OPEN FILETRANSFER" in the docs).
I suggest you use an open protocol like HTTP or FTP instead.

Categories

Resources