I was searching for a method to change Outlook Emails to HTML. I found one method that uses VBscript, but it only changes the Outlook File to Text.
Edit: I'm looking for a way to automatically save hundreds of emails to HTML format.
There are number of ways to go here:
Set up a rule to run a script
Wire up a VBS script to fire when you receive and email
Write and Add-in to do the above.
The advantage of the Add-in is that it can be easily deployed compared to rules and scripts, but it a little more complicated.
Number 1 Is probably the easiest to set up if you have no experience.
Open the Visual Basic Editor (Alt+F11) or off the tools menu > Macro
Click on the ThisOutlookSession node on the left
Copt this code in to the right hand page
Sub CustomMailMessageRule(Item As Outlook.MailItem)
Dim HtmlMessagePath As String
HtmlMessagePath = "C:\Users\Marcus\AppData\Roaming\KnowledgeMill\html\" + Item.Subject + ".html"
Call Item.SaveAs(HtmlMessagePath, OlSaveAsType.olHTML)
End Sub
4 .Change the paths and may be use the Item.EntryID as the file name as you could get filename problems with subject you may also want to use mhtml so that you get everything in one file.
5.Create a Rule using the rules wizard and get it to fire on new emails and then to run a script. Click on the Blue script links and select the new script.
6.You may have to adjust you macro security to allow the script to run. (N.B restart outlook after you do this)
You can acutally view the email in a browser in outlook 2007. The option is under under 'other actions' in the ribbon.
You can save the email as html too!
You can set up rules to print emails automatically. I would just set up an HTML printer on your computer.
Related
According to this Microsoft dev guidance, it should be possible to have a element on a web page do a POST via the method=POST attribute of the form. It shows an example of HTML needed in order to open a report viewer to a report and render the HTML viewer. I have that working. I would like to use the exact same technique to create a PDF or Excel file, but it doesn't work when I update the Format parameter to either PDF or EXCELOPENXML. Instead it ignores that parameter and provides the HTML viewer anyway. I would like to stick to one technique for both opening the HTML viewer and for downloading the various file formats. Does anyone know a workaround? I have considered a generic function to take the hidden elements and tack them on to the action URL, and open a new window with that. Does anyone have the code to do that?
I would still be curious to know if there's an issue with the POST action for file exports, but in the meantime, I solved it with this:
$("form").find(":input[name]").map(function(val, key) {
return encodeURIComponent($(this).attr('name'))
+ '='
+ encodeURIComponent($(this).val()).replace(/%2C/g,',').replace(/%20/g,' ');
//unencode space and comma characters for convinience and shorter URLs
}).get().join("&")
I have requirement to save a html file as .msg format so that it can be sent later. The html of type of mock of normal mail with only basic features (from, to, cc, subject, body). Not sure how it can be achieved.
Other way is disable the send button of new outlook email so that it can be sent later. I do not think that this can be achieved.
Any clue would be great help, stuck with this since a long time.
I read in some websites that there a specific format for this but it not get any template or example for it.
You are on the right avenue, web-based Outlook add-ins don't allow disabling the send button. Also, there are no methods for creating items based on a template. You can simply set properties separately based on the data you have.
You may consider developing a COM-based (for example, VSTO based) add-in instead where you can create items based on the template and do the required UI modifications. See Walkthrough: Create your first VSTO Add-in for Outlook for more information.
I have been searching the internet for hours to find a solution to my question.
I know how to import mails for a long time, but can't keep the format of the HTML-body like I could do when copy the body from OL by hand into the Rich-text memo field on an access form.
The field (olbody) is bound to a SQL server table field olbody (nvarchar(max)) and could store html mail body text when I insert the content of the clipboard.
I even tried to read the .HTMLbody property in the clipboard
clp.SetText .HTMLBody
clp.PutInClipboard
and then I pasted manually the content of the clipboard with Ctrl+V in the field, but again, it does no show up like the HTML mail. But I can see all HTML commands, which should format the mail.
Without formating the mail in the access field, the content is almost unreadable because no tab, lineskip etc. is in the body.
Any help welcome.
Thanks
The proper way to display HTML is using a web browser. This means: use the web browser control!
You can load the HTML in the webbrowser control on load, and when your mail field changes.
Example code:
Private Sub Form_Current()
Dim wb As Object
Set wb = MyWebbrowserControl.Object
With wb
.Navigate2 "about:blank"
Do Until .ReadyState = 4 '=READYSTATE_COMPLETE
'This is a somewhat inefficient way to wait, but loading a blank page should only take a couple of milliseconds
DoEvents
Loop
.Document.Open
.Document.Write MemoField.Value
.Document.Close
End With
End Sub
Replace Memofield with your mail field, and MyWebbroserControl with your webbrowser control, and you should be ready to go.
Note that you probably should use the Access web browser, and not the ActiveX web browser. This code will work with both, but the Access web browser control uses a more modern version of IE, and doesn't come with a non-removable border.
I'm trying to call an outlook procedure from VBScript.
Bellow is my VBScript code (its not working)
Set objOutlook = CreateObject("Outlook.Application")
objOutlook.run "Call_outlook_macro"
objOutlook.Quit
Set objOutlook = Nothing
Please help me.
EDIT:
Basically, I wanted to call outlook macro by clicking a hyper link (using HTML tags and href, I'm not very good with HTML) in incoming mail(this will be sent from servers). But I couldn't find a way to use hyperlinks to call macros.
The work around to this was to create a VBScript to call the outlook macro. I can easily fire a VBscript using a hyper link.
Also, the outlook macro I'm trying to call eventually opens up an outlook form.
If there's a way I can fire outlook macro using hyperlink in the mails, that would be great.
Try
objOutlook.mySub()
instead of objOutlook.Run "Call_outlook_macro" like suggested here.
mySubhas to be in ThisOutlookSession module.
What is your Outlook version? This will not work with all versions how-to-call-vba-macro-from-vbscript-in-outlook-2010.
If you can't call a procedure, you can adapt the sub to VBScript and use it directly, instead of calling it from Outlook.
Alternative: write an Add-In like suggested here handle-hyperlink-click-event-in-outlook-mail.
Alternative 2: Open form with javascript as suggested here To launch a custom Outlook form from a Web page.
There is no way to call a VBA macro from message bodies (hyperlinks). A new Outlook form is shown because you create a new Outlook Application instance:
Set objOutlook = CreateObject("Outlook.Application")
Try to use the GetObject or GetActiveObject functions instead, see GetObject or GetActiveObject cannot find a running Office application for more information.
I'm attempting to send HTML formatted emails using C# 3 via Outlook.MailItem
Outlook.MailItem objMail = (Outlook.MailItem)olkApp.CreateItem(Outlook.OlItemType.olMailItem);
objMail.To = to;
objMail.Subject = subject;
objMail.HTMLBody = htmlBody;
The email is generated externally by saving from an RTF control (TX Text Control), which yields HTML with links to images stored in a <<FileName>>_files subdirectory. Example:
<img border="0" src="file:///C:/Documents%20and%20Settings/ItsMe/Local%20Settings/Temp/2/zbt4dmvs_Images/zbt4dmvs_1.png" width="94" height="94" alt="[image]">
Sending the email this way generates a mail with broken links.
Using Outlook 2007 as the email client with Word as the email editor, switching to RTF (Options tab, Format tab group) preserves the layout and inlines the images.
Programmatically doing this via:
var oldFormat = objMail.BodyFormat;
objMail.BodyFormat = Outlook.OlBodyFormat.olFormatRichText;
objMail.BodyFormat = oldFormat;
loses the formatting and mangles the images (the image becomes a [image] link marker on screen which is clickable but no longer shows the image). This isn't a surprise given that the documentation for MailItem.BodyFormat Property says "All text formatting will be lost when the BodyFormat property is switched from RTF to HTML and vice-versa".
Sadly there doesnt seem to be an easy way to change the Type of each Attachment in the MailItem.Attachements to OlAttachmentType.olByValue, as it's a read-only property that's set when you create the Attachment.
An approach that comes to mind is to walk the HTML, replacing the <img> tags with markers and programatically walking the MailItem text, inserting an Outlook.Attachment of Type OlAttachmentType.olByValue.
Another option is to convert the <img> links to use src="cid:uniqueIdN" and add the images as attachments with the referenced identities.
So, to the question... Is there a way to get the linked images converted to embedded images, ideally without getting into third party tools like Redemption? Converting to RTF happens to yield the outcome, but doing it that way is by no means a pre-requisite, and obviously may lose fidelity - I Just Want It to Just Work :D Neither of my existing ideas sound Clean to me.
Since you are using .net > 2.0, you may want to look into the System.Net.Mail namespace for the creation of mail messages. I have found that its quite customizable and was very easy to use for a task similar to yours. The only problems that I had was making sure I was using the right encoding, and I had to use HTML tables for layouts (css would not work right). Here are some links to show you how this works...
Basic
With multiple views (Plain Text and HTML)
If that's not an option, then I would recommend going the Content ID route and embedding the images as attachments. Your other option is to host the images publicly on a website, and change the image links in the html to the public images.
Something that you should be cognizant about is that HTML emails can easily look like spam and can be treated as such by email servers and clients. Even ones that are just for in-house usage (its happened to me) can end up in Outlook's Junk Mail folder..
DOH!, actually sending the email in Outlook 2007 forces the images to become embedded.
The Sent Item size of 8K is a lot smaller than the draft size of 60K (RTF) I was seeing vs the draft size of 1K (HTML that hadn't been converted to RTF and back again).
So it was Doing What I Mean all the time. Grr.
I'll leave the Q and the A up here in case it helps someone of a similarly confused state of mind.
BTW some useful links I found on my journey:
Sending emails example
General Q&A site with other examples of varying quality