How to append x-header information in generated .eml / .msg file - eml

My requeriment is to open the email content to,cc,subject,body, attachement retrive from DB and open the content in user email client ( Outlook ).
To achieve this i'm creating .eml/.msg file with the retrieved information and saving into the local disk and opening the .eml file, all this flow happens programmatically in C#. But when the content opened in outlook email client it opens as send mode( Although when opening a email to read/send).
I want to open the email in differnet mode Compose/ Reply/ Forward. When i gone through many article understand have to add x-header when generating the .eml file will do the magic. But i'm sure how to achieve this solution.
Can anyone help ?

var mail = new MailMessage();
mail.Headers.Add("X-Unsent", "1");

Related

body of email with hyperlink to windows-like path (from unix-like path)

I am writing a python script that, from within a Unix environment, should transfer some .pdf reports to a network drive accessed by other colleagues, who always access them on Windows. Upon transfer of the reports, my script sends them an email saying that the reports were transferred to a specific location and now I am trying to create a link in the body of the email that will redirect them to the location where the reports have been transferred to.
On Unix the reports are located at /DriverName/the/rest/is/the/same
Whereas the path on Windows looks like \\driverName\department\subDepartment\the\rest\is\the\same
So eventually I want my colleagues to be redirected to \\driverName\department\subDepartment\the\rest\is\the\same when they click on the text /DriverName/the/rest/is/the/same on the body of the email (shown below)
link_name = '/DriverName/the/rest/is/the/same'
body_html = f"<p>Reports of regular NIPT samples can be found at <a href='file:///\\driverName\department\subDepartment\the\rest\is\the\same'>{NIPTDIR_Hdrive}</a><p>"
My email gets sent and the text /DriverName/the/rest/is/the/same becomes clickable, though the path is not found when I click on it. I am quite sure the issue has to do with forward slashes / on Unix vs. backslashes \ on Windows.
Does anyone know how I can 'translate' the (windows-like)path \\driverName\department\subDepartment\the\rest\is\the\same to a unix-like path, so that I can use in my python script?

Insertion of Link(href) in JSP to open Excelsheet not working in IE

I am inserted an href Link to open Excel Sheet(already existing in Server directory) in a JSP page. It is working perfectly fine in local eclipse browser but unable to open the sheet in InternetExplorer (client side). The snippet is as below.
This link will open the Excel Sheet
Now, it is working perfectly fine in InternetExplorer 7 (client side) also, because I have used the server path in workspace of eclipse to store the excel sheet folder , the path is as follows
Server path for File :C:\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Log‌​inExample\Sheet\SparesUsed.xls.
But when i open and try to edit the excel sheet , it is giving me error "Sparesused.xls is read only". To save a copy ,click ok, then give workbook new name in saveas dialog box".
But I cannot allow the user to change the location of the file using saveas button because this same sheet would be used and open again & again using href link of jsp. i am using Tomcat6.0 version of server
The snippet you posted is incomplete html code.
If the anchor tag is closed properly, browsers will offer to download the file or open it with Excel. This very much depends on the browser and version used. "not working in IE" is a bit too broad, since there are several generations of Internet Explorer active out there that all behave differently in some situations.
IE does not "open" an Excel spreadsheet by default. If anything, it will push the file to load with Excel.
What do you expect to happen?
Browsers don't open Excel files. Some servers support Excel Web apps and you may be able to open the odd Excel file and it will display in the browser, and if you are lucky, you may even be able to change a text value or a number. But be aware that currently this is the exception.
As a general rule: a complex Excel file can not be opened and edited in just any browser of your choice.
Excel is a quite complex application and it cannot be expected that all of Excel's funcionality magically appears in your browser, just because you post a link to an Excel file.
If that is not what you expected to hear, please rephrase your question.
Iam Using This Approach now.
Iam using Server Path to save/store the Excel Sheet , which can be browsed anywhere from client side.
DownLoad Excel Sheet .
Thanks for Help.

Contact Form that is not a .php extension

recently i have been trying to so make a contact form work and i finally did after hours of struggle.
http://trulyamped.com/democon/contact2.php
This contact form works perfectly and the email gets sent to my account.
The only thing i wanted to know was how do i make the contact form work in an .html file. I do not want it to be in a .php file. I already tried to save the file as an .html file but it did not work. Please let me know.
so pretty much i want it to be contact2.html and still be able to work.
First of all, why does it matter?
But assuming for a moment that it does matter, you probably have a couple of options. They depend on where your code resides and what it currently does. If the page has PHP code that needs to execute server-side then it needs to be processed by the PHP interpreter server-side. To do that with an HTML file you'd need to configure the server to treat .html files just like .php files for server-side processing. This isn't ideal, though. HTML by itself doesn't need to be run through the PHP interpreter. So it's best to keep the PHP and HTML files separate.
Another option could simply be to separate the client-side HTML form and the server-side PHP code into two separate files. Something like contact.html and contactProcessor.php. In the HTML file you'd just post to the PHP file in the form. Something like this:
<form action="contactProcessor.php" method="post">
This would cause the form to post the data to the PHP file. Then the PHP file can process the data, do whatever you're currently doing server-side, and redirect the user to another HTML file as a response. So at no point would the user be "viewing" a PHP file. There's just be one used to handle the form post.
Again, I can't imagine why it matters though.
You would need to create a 2nd page that only has the email processing logic, let's call that email.php you could then update your form to post to email.php and change this page to be contact2.html as long as it posts to a .php file it will work.
<form id="contact-us" action="email.php" method="post">
Your bet is to use AJAX for the main form but will still need a server side script page to handle the mail sending. As far as I know, it's not possible to send mails from the client side.
So
Have the PHP page that actually sends the mail in a separate script file
Create your form in HTML and use AJAX to call the mail sending script from within your HTML page.
This way you can have your page in html and do the mail sending at the background.
Regarding saving your page with .html extension, of course it wouldn't work. Because your page contains PHP which is server-side and needs a web server to run, while html can be run on any simple browser on any device.

How do I make a button link that will download a file to the users computer once clicked?

I have several buttons on a Download page that I want to link to different movies stored on the server so that once the user clicks the download button the movie will download to their computer. How do I do this? I thought it was simply a case of putting the directory path to the relevant file into the link for the button?
Here's the page: http://www.infomaticfilms.com/jack/infomatics/download.htm
Any help would be appreciated.
Jack
I assume that you want the user to be presented with a Save As dialog instead of just opening the file in the browser?
There are really two components that make this happen:
The user's browser is configured to download that type instead of open it directly. You have no control over this, it's up to the user's own configuration.
Your server suggests to the browser that it should download that type instead of open it directly. This is done via a header value in your server's response.
The header you're looking for is called Content Disposition. How you use it is up to your server-side capabilities. But basically you want to set it to something like:
Content-Disposition: attachment; filename="filename.mpg"
This response header tells the browser that what you're sending it is a file and should be locally saved as one. (Remember that HTTP by itself has no notion of "files", only requests and responses with headers and data.)

Can you locally create a HTML form that outputs a .txt file to be saved?

Can you create a html form that can be housed on a USB flash drive and opened up in a browser that allows someone to enter info and then allows them to save what they entered as a .txt file back to the same USB? Any ideas or resources you can point me to?
Not a full solution, but maybe it gets you on the right track:
Generate a usual HTML page with a form to enter all information necessary.
Then use JavaScript to build a string containing all data you want to store inside the textfile.
Create a Blob() object out of it (MDN docu) - the type application\octet-stream is important to force a download later on:
var myBlob = new Blob( content, { "type" : "application\/octet-stream" });
Convert that blob to a DataURL using window.URL.createObjectURL (MDN docu):
var dataUrl = window.URL.createObjectURL( myBlob );
Update the location of your browser tab using window.location and set it to your data url:
window.location = dataUrl;
The user will then have the usual "Save file as ..." dialog for your generated textfile. Note, however, that this way you are not able to set the name of the textfile!
Not directly. Since this type of form processing has to occur server-side, you need a web server.
Now, it is entirely possible to run Apache or something similar from that flash drive, and have PHP or something do your file writing. This isn't as straightforward as you are looking for, but is possible. Keep in mind that not everyone has autorun enabled, that folks use different OSes, and that firewalls are often picky about new applications opening up ports.