Does Outlook web add-in access to .msg file - exchangewebservices

My previous VSTO can output the .msg file. But can this be achieved in the new web add-in?
Any code examples?
I am currently using office.js in the front end and EWS managed API in the back end.
Instruction
I have found the above post saying something about that but I cannot integrate into my back end.

Turns out I need to get the itemID first to get the EmailMessage .
ExchangeService service = new ExchangeService();
service.Url = new Uri(ewsUrl);
service.Credentials = new OAuthCredentials(ewsToken);
EmailMessage em = EmailMessage.Bind(service, new ItemId(itemID));
I can use Office.js from the front end to gather those prerequisite info(ewsUrl,ewsTokenitemID)
At this point I can just load the eml by
email.Load(new PropertySet(ItemSchema.MimeContent));
MimeContent mimcon = email.MimeContent;

Related

How long does the User Token/Client last with Box Platform API?

I'm developing a server-side application to upload files to Box. I'm using the Box .NET SDK, using JWT for authentication.
Here's how I set up my Box stuff:
var boxConfig = new BoxConfig(clientId, clientSecret, enterpriseId, jwtPrivateKey, jwtPrivateKeyPassword, jwtPublicKeyId);
var boxJwt = new BoxJWTAuth(boxConfig);
var userToken = boxJwt.UserToken(boxAppUserId);
var userClient = boxJwt.UserClient(userToken, boxAppUserId);
Then I use the UserClient object to upload a file to Box once a day.
My question is: Will that UserClient or UserToken ever expire? I want to know if I should get a new UserToken and instantiate a UserClient every time I need to use it, or if I could initialize all these things just once when my application starts up.
The token will expire after roughly one hour. The client is designed to fetch a new user/admin token as necessary so you shouldn't need to worry about it after the client is initially created. You might even try specifying a blank token when initializing the client and let the re-authentication logic handle things from the beginning:
var userClient = boxJwt.UserClient("", boxAppUserId);

EWS emails with HTML BodyType

I have an application that periodically polls an 2010 exchange server email inbox for emails with a certain subject.
I am using c#, .Net 3.5 in VS2008. I can successfully connected to, retrieve all the emails I require.
If the Body of the email contains XML which is validated with an xsd, usually this is working fine but when the email has a BodyType of HTML the xml tags are not displayed and it fails the xsd validation.
If I do a show source on the email body the xml tags are all there. My question is, how do I get the actual xml text and not the html text?
I initiate the service using
m_Service = new ExchangeService(ExchangeVersion.Exchange2010);
I am returning the search results using this...
public void getEmails(string searchType)
{
ItemView itemView = new ItemView(int.MaxValue);
SearchFilter searchFilter = new SearchFilter.ContainsSubstring(EmailMessageSchema.Subject, EmailSubject);
SearchResults = Service.FindItems(GetFolderName(searchType), searchFilter, itemView);
}
and loading the individual emails
foreach (Item item in SearchResults)
{
item.Load();
EmailMessage mes = (EmailMessage)item;
string emailBody = item.Body.Text;
}
it is possible to get PR_HTML MAPI property. You can added as extended property in your request. It works with Exchange Web Services .NET, but should also work with EWS Managed API

How to display push notifications using SignalR in MVC

I am using SignalR in MVC to display information in a basic chat type device in MVC. This is all working ok but I want to display information from a Json payload that has been deserialized like this:
Dim iss As IssueObjectClass = JsonConvert.DeserializeObject(Of object)(json)
The information does not have to being displayed does not just have to be an object it could be a variable as well, for example I could also display this:
Dim key = iss.issue.key
I have the code for the connection using the chat hub device which is displaying basic information (Message and username). Is this the way that I should try and display my Json using SignalR. I know that SignalR is used for real-time web applications but I am unsure on how it could display information that has been fired from a webhook as a Json payload.
This is how I am displaying the messages in the chat hub, but I want to display information that is coming from a webhook unrelated to anything that has been typed on the application. I want to display information from a HTTP POST from JIRA:
var encodedName = $('<div />').text(name).html();
var encodedMsg = $('<div />').text(message).html();
$('#discussion').append('<li><strong>' + encodedName + '</strong>: ' + encodedMsg + '</li>');
$('#discussion').text = encodedMsg;
How can I integrate SignalR with Json to display it?
It's a pretty simple thing to do, and a common case with SignalR. In your code where to receive and deserialize your object, you just have to call something like:
var context = GlobalHost.ConnectionManager.GetHubContext<YourHub>();
context.Clients.All.broadcastIssue(iss);
On your client you'll have to define a handler this way before you start the connection:
var yourHubProxy = $.connection.yourHub;
yourHubProxy.client.broadcastIssue = function (iss) {
// ...do your stuff...
};
This is very basic code which would need to be better organized, but it should put you on the right track. My advice is you go through the official SignalR documentation, which is extensive and well done, in particular the guides to the APIs.

Create OneNote (client) Notebook with OneNote API

I can use the code below to create a page in a section and I can create a Notebook in the OneNote OneDrive using the APIGee console app, but I cannot figure out how to create a new Notebook in the OneNote client program. Below is a snippet of my code to create a page in the Foo section.
How can I modify this code to create a new Notebook in the client?
private static readonly Uri PagesEndPoint = new Uri("https://www.onenote.com/api/v1.0/pages?sectionName=Foo");
HttpResponseMessage response;
using (var imageContent = new StreamContent(await GetBinaryStream("assets\\SOAP.jpg")))
{
imageContent.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
HttpRequestMessage createMessage = new HttpRequestMessage(HttpMethod.Post, PagesEndPoint)
{
Content = new MultipartFormDataContent
{
{new StringContent(simpleHtml, System.Text.Encoding.UTF8, "text/html"), "Presentation"},{imageContent, imagePartName}
}
};
// Must send the request within the using block, or the image stream will have been disposed.
response = await client.SendAsync(createMessage);
}
tbResponse.Text = response.ToString();
return await TranslateResponse(response);
If the create notebook API call returns a success (201), it means the notebook has been created successfully on the user's OneDrive. However, the notebook will not automatically show up in the OneNote clients for the user. The user will need to open the newly created notebook in one of the OneNote client apps.
Alternatively, you can use the links.oneNoteClientUrl.href property from the API response message to open the notebook for the user in the OneNote client for them.
Hope that helps.
Thanks,
James
If you have OneNote installed, you may use the OneNote COM API. There is a VanillaAddin you can modify here: https://github.com/OneNoteDev/VanillaAddIn
In addition you can just write a Console app using the same COM API to do this (so you don't need to write a COM Add-in).

SSRS - Obtaining the physical report files

Basically I have a reports server which contains loads of "My Reports" reports which I need to migrate to a new SSRS server.
Question:
Is their an easy way to obtain all the physical.RDL files without having to export the files one-by-one from the old server interface and then upload using the new servers interface?
Looking forward to your reply
Steven
There is a third party tool available here that will allow you to batch download / upload rdls.
http://sqldbatips.com/showarticle.asp?ID=62
You could write a small .NET app to retrieve them all, using the SSRS Web Service API. The article on the GetItemDefinition method has sample code to get a single file, here's a relevant snippet (copy/paste alert!):
ReportingService2010 rs = new ReportingService2010();
rs.Url = "http://<Server Name>/_vti_bin/ReportServer/ReportService2010.asmx";
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
string reportName = "http://<Server Name>/Docs/Documents"
+ "/AdventureWorks Sample Reports/Sales Order Detail.rdl";
byte[] reportDefinition = null;
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
try
{
reportDefinition = rs.GetItemDefinition(reportName);
MemoryStream stream = new MemoryStream(reportDefinition);
string myDocumentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
doc.Load(stream);
doc.Save(Path.Combine(myDocumentsFolder, "Sales Order Detail.rdl"));
}
If you write a little loop around (part of) this code you may be able to quickly grab all the files.