Is it Possible to Reply From an .EML file? - c#

I would like to know if it is possible to open and reply as a response message on top of a saved .eml file using C#?
If yes, are there any guides that I can follow?
I am able to do so with EWS EmailMessage where the message resides in Inbox. However, due to requirements, I am required to retrieve and reply from a saved .eml file instead of replying from the email in Inbox directly.
Thank you.

No you can't do this using the EWS reply operations because EWS is a Server side API while using the EWS Managed API you using Client side library that just instrumenting the SOAP call to the backend whenever an action is taken. You can temporary import the EML back in the server https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-import-items-by-using-ews-in-exchange and then you reply and then delete the Message again if don't want it to exist. If your want to send using EWS you didn't want to import the message use something like mimekit to generate the MIME of the response message offline http://www.mimekit.net/docs/html/Frequently-Asked-Questions.htm then you can just sent the Mime generated by mimekit via EWS.

In theory you could achieve this, by first opening the EML file (please see this question and answer):
Retrieve Email Information from .EML Files
And then when you have the contents of the message in code, copy the data over to whatever email-sending API you are using.

Step 1:-
Click the message options menu in the top right corner of the message. Select Save email.
Step 2:-
Save the file. The file name will default to the subject line of the email, with special characters removed. Your download options depend on whether you're using Front on the web or in the desktop app:
*Web: Your file automatically saves to wherever you have it set up in your browser settings (like your Downloads folder)
*Desktop app: You will get the “Save As” prompt where you can rename the file and choose your download location
Step 3:-
You will see your .eml file in your chosen location. You can attach it to a message via drag-and-drop or with the attachment file picker.

Related

Email highcharts pdf

I managed to export multiple charts as pdf and download it on client side. Is there a way to email that pdf to email that user types. I was not able to find anything. I am using .net framework on server side.
Is it possible to send pdf to server using ajax and to send it to email from server that way?
Assuming that you've got the PDF content and the email address to send it to from the client side, you can send email via .NET from your back-end server. This used to be done via the built-in SmtpClient class but Microsoft now recommends people to use other options like MailKit instead.
You're also going to need an email server to connect to which will handle the delivery of those emails. This could be Gmail if you already have an account or an alternative like SendGrid
As far as getting the PDF content of the chart, Highcharts appears to be taking the SVG content of the chart and using svg2pdf to produce the PDF when not using an export server.
Since there appears to be no (documented) way of exporting to anything other than a file, you're likely going to need to mimic this process yourself by taking the SVG content via chart.getSVG() and then using svg2pdf to get your PDF content to send to your server.
Highcharts is a client html2print generator and like jsPDF or other client based solutions the PDF generation is per user selection of PDF printout options. (The client has control over PDF so no need for them to email it to self or others, unless they have to.)
Per link above
However, for situations where you may be generating a report for a client who has just seen the screen (and you don't need to change the chart in anyway) - why would you want to render the chart server side? when the client has already done the work.
To build server side automatically using a browser the server needs generally to process it, just like a user, with say chrome --headless options for html2pdf (and chrome can normally do that in one line, but with limited user layout options).
At that point you could have a PDF for attachment by any conventional mime application/pdf means (e.g. convert to base64.txt).
However due to the more dynamic drawing of svg (rather than a static insert) I could not run an Out.PDF --headless just by CLI, so it would need a driven solution such as selenium/puppeteer. THUS you may need to follow the suggestions in the lee-m above answer to build and modify the svg output.
for me I was able to run printEdge.vbs (with my current landscape defaults)
DIM shell
SET shell = WScript.CreateObject("WScript.Shell")
Shell.Run "cmd /c start msedge.exe file:///C:/Users/WDAGUtilityAccount/Documents/highchart.htm"
WScript.Sleep(4000)
Shell.SendKeys "^p"
WScript.Sleep(3000)
Shell.SendKeys "{enter}"
WScript.Sleep(1000)
Shell.SendKeys "{enter}"
WScript.Sleep(1000)
Shell.SendKeys "y"
WScript.Sleep(1000)
Shell.SendKeys "{esc}"
WScript.Sleep(1000)
Shell.SendKeys "%{f4}"

Is it possible to send an attachment in Outlook as a URL

I have an Outlook addin that handles attachments by sending them to our server and then embedding a link into the body of the email containing the URL to the uploaded attachment.
This works but it is not 100% satisfactory because the URLs can get broken depending in the email client and the sender will not see their attachments listed at the top of there email where they are use to seeing them.
Ideally what I would like to do is exactly what is being done for OneDrive.
Currently if I add an attachment and provide a URL as the source it will download the file and send it as a normal attachment which is the exact opposite of what I want. I have noticed that if it fails to download the file it will then just send the URL as an attachment which is what I want. But sending broken URLs is not very useful.
Using
Outlook.MailItem.Attachments.Add("https://myserver.com/somefile", 7, 1, "MyAttachment")
If I set the attachment type to '7' which is what is used for OneDrive attachments I can get it to send the URL but it will first complain about not being able to set some access rights and if the sender clicks OK to continue anyway the attachment will appear to the sender and the receiver as residing on OneDrive which it is not, but clicking the URL will download the file from my server as I want.
My question is: Is it possible to send a none OneDrive URL as an attachment?
(I expect the answer is no, but I am hoping some Outlook guru out there may know some trick to do this.)
My other alternative it to wrap my URLs in an small html file that is then sent as a normal attachment and when opened will provide the link to the actual file.

attachments with ics file in c#

I am trying to send an ICS (calendar) file to someone that read it using Office365, using C#.
Sending just the ICS works fine. But I have to attach a file.
At this point, the mail is received without calendar, or the calendar is attached to the email and cannot be used, or the attachment is missing.
I tried 2 different ways:
1. send attachment inside VEVENT, using ATTACH;ENCODING=BASE64;VALUE=BINARY;X-FILENAME=file.txt:, but this does not show any attachment in Office365 (like here: Attaching a file to an iCalendar)
2. send attachment as a separate file, and attach it to VEVENT using ATTACH:CID:, but this time the calendar file is displayed as attachment
The second way should work if I can format the mail message to look like this:
multipart/mixed
multipart/alternative
text/plain
text/calendar;method=REQUEST
text/calendar (with a content-disposition:attachment)
(as described in Multipart email with text and calendar: Outlook doesn't recognize ics)
If I send a calendar invite using Outlook365, the message looks like that.(but instead of the calendar as attachment, the image or doc is attached)
but using System.Net.Mail.MailMessage, I can generate a message like this
multipart/mixed
multipart/alternative
text/plain
text/calendar;method=REQUEST
multipart/mixed
text/plain (with a content-disposition:attachment)
Desktop version of Outlook 2007 shows both calendar and attachment, so it seems that Outlook365 is very strict about the format.
But how can I send, using .NET classes, an email that does not have the extra multipart/mixed section? MailMessage class generate for the Attachments collection a new section with content type multipart/mixed, insead of adding them to the top level.

Creating a Dynamic iCalendar Feed

I am looking for a means to generate a iCalendar feed using .Net , atm I am using the DDay library to generate the iCal file and write it to the response.
The problem with this is if I feed the URL to outlook it says that it is a invalid ics file.
I have tried various routes including :
Using MVC routing so that the link contains a .ics extension.
Changing the Mime Type so that it is Text/Calendar.
One observation I have found is that if I navigate to the URL in a browser a valid iCal file is generated and is imported into Outlook correctly. Secondly if I take that exactly file and host it via IIS as static content , Outlook picks it up as a valid file.
The problem is that I need to generate a Dynamic feed and seem to have run out of things to try and get this working.
It seems the problem in my case was that the default asp.net auth was blocking outlook because it was not authenticating , once a exception was added to the web.config , the URL loaded correctly in outlook

How to identify whether the client machine supports PDF File format

Hii,
My requirment is to show a dynamically created pdf file directly to my web page. It works fine for the system which is having pdf reader software. But for the system which does not have the pdf software it is showing error like below
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
An invalid character was found in text content. Error processing resource 'http://localhost:4252/OmanePost/Customer/EBox/PD...
I need to handle this situation bit differently.i.e In this situation the file should be save to the physical location of the system for that i need to identify whether the client machine has pdf software or not then i can manage properly
I m using ASP.NET 2.0 version
It looks to me that you are serving your PDF with an XML mime/content-type. Make sure you set your content-type to application/pdf and you'll probably get a more suitable browser response.
In this case the browser should ask the user to open the file in an external application.
Please verify that you are sending the correct Content-Type: application/pdf header. Certain versions of Microsoft's browser ignore the content-type header, so you need to specify a filename ending in .pdf in the content disposition header: Content-Disposition: inline; filename=filename.pdf;
Note: I have not verified that it works with "inline" instead of "attachment", but I think it is worth a try.
My requirment is to show a dynamically created pdf file directly to my web page.
Try online ZohoViewer that takes a PDF file link and displays in the browser without requiring PDF reader on the client machine. As such there's no way to check if the client machine has a pdf reader or not.
You can not identify that client system has pdf software using javascript, asp.net, c#.
If the PDF reader software is not there and the PDF is a valid PDF then it should not throw exception. Instead it asks for a software in client machine which can read the file.

Categories