How to insert a clickable hyperlink with Outlook AddIn? - html

I am working on an Outlook AddIn which pastes a text in the body of email.
I am not using any of the following.
email.Body
email.HTMLBody
Instead, I use:
email.GetInspector.WordEditor.Content.InsertBefore()or InsertAfter()
The reason of that choice is justified by the fact that the latter mentioned line of code keeps the email formatting, the default user's fonts, as well as the signature formatting.
Now, when I try to paste a link into the email, it doesn't appear as a hyperlink, but just as a string. My link only becomes a clickable hyperlink when I click space or enter after it.
I can't use the URI class because I am also pasting text in a string format along with the link.
I tried to add the tags myself and saved the email as .htm here is the line where my link is posted. The tags are not translated into HTML.
<a href="http://whatever.com">http://whatever.com</a>
And if don't put the tags myself, it's just the same thing, but without all the &quot, &gt, &lt... and of course no HTML tag, which makes no clickable hyperlink.
Anyone knows how to fix this ?

The Document class from the Word object model provides the Hyperlinks property which returns a Hyperlinks collection that represents all the hyperlinks in the specified document.
You need to use the Add method of the Hyperlinks class. It returns a Hyperlink object that represents a new hyperlink added to a range, selection, or document.

Related

Unable to copy the cell color from excel to outlook

I am unable to copy the entire cell format (ex. cell color) when using vba code to send emails to client using excel
I want to copy the cell color to outlook. The formula only let me copy the cell value only.
In case of HTML you need to get the required formatting from Excel objects and then set up HTML attributes (or styles) on your own.
You can also use the Word object model for copying and pasting the data with formatting. The WordEditor property returns the Microsoft Word Document Object Model of the message being displayed. The returned Word Document object provides access to most of the Word object model. See Chapter 17: Working with Item Bodies for more information.
Also be aware, the HTMLBody property in the following piece of code returns a well formed HTML document:
Signature = OutMail.HTMLBody
But later in the code you add some HTML markup before the document begins which is not correct. Even if Outlook handles such cases correctly, there is a possible mistake if the behavior is changed at some point. Keep the HTML markup well-formed inserting the content between the opening and closing <body> tags.

How can I get our WYSIWYG editor to stop removing HTML comments, CSS classes and inline styles?

We currently use wysihtml5-rails to let our users edit emails before they are sent but this is not working out so well for a few reasons.
I need the comments to allow for Outlook specific comments like these . All comments are being removed, currently.
I also need the CSS classes to be untouched as the editor content will be a pre-generated email that includes CSS classes. Our editor will only keep classes that are whitelisted but this is annoying as we need to update that list with every change.
Same goes for inline styles. Some of the styles in the generated email are inline instead of in classes. Those need to be kept but they are being removed.
Is there any way I can get our editor to work this way?
I found a solution but it's hacky.
I realized that the raw HTML was being stored on the page in a hidden textarea tag. Interestingly, all the elements that I needed (CSS classes, comments) were still there. But when submitting the form, the value of this textarea was replaced with the parsed results from the editor which gets sent to the server. All the comments and classes are gone from this text.
The solution was then to create a second field that takes the unparsed value from the WYSIWYG editor and sends that along. Easy in rails but just making this new field part of a form. Then the controller can choose which value to take. In my case, I renamed the existing message field to parsed_message. Then added a new message field which will hold the unparsed message.
The WYSIWYG editor we are using allows this by having a method that can be called at any time: window.email_editor.getValue(). Here the email_editor is the editor instantiated by the javascript on the page.

Google App Script. How can i get hyperlink name?

Have troubles with extracting url from text in google document. I found method getLinkUrl(offset). It works fine, but if i for example add link not directly to text but via menu item Insert -> Link i can specify some name for link, for example name, that will be displayed in text will be StackOverflow and the link is https://stackoverflow.com, so when i use method getLinkUrl() i will get hyperlink but not the name. I need to get position of this link on text, so i need to get this word StackOverflow but i didn't find corresponding method for this.
Is someone know how i can get this word or its start and end indexes?
I know about attributeIndices property which contains indexes of starting of special formatting of text and it can be used in this case, but if link is last word in paragraph, there is no any more attribute index in this array, so i can not determine length of this word.
Would be appreciate for any advice)

force email client to display html address as text and not as link

My web application sends emails to subscribed users.
The email is formatted as an html page and contains html addresses specified as plain text (not inside href tag).
The intent is for the email client to display the html address as simple text, one that the user can "paint" with the cursor and copy to clipboard
This works just fine in some email clients (for example yahoo). However,
other clients (for example, MS outlook and gmail) detect these pieces of text, and display the html address as a link, making it difficult for the user to do the paint-copy-paste described above.
I tried the following:
wrap the text in CDATA block - gmail then disregards the whole block
escape the html address (instead of http://... --> http://...) - makes no difference (still make a link out of text)
any ideas?
you could but a double :: to disable the parsing:
http:<span style="display: none;">:</span>//google.com/
This will not show the second : and should avoid the parsing.
EDIT:
This will work:
http<span>:</span>//google<span>.</span>com/

QListView custom display

I have a QListView with a Custom Display based on a simple contacts list. All the fields EXCEPT the email address field render just fine, and the items on the page otherwise look exactly as formatted. There is definitely data in the field, but this one simple text field isn't rendering as a mailto link in the QListView. The href code is correct, it works when tested in a simple html file, but not on the Sharepoint page.
Viewing source, all I see for the email code is literally mailto:<%EmailAddress%> where it should show mailto:myname#mydomain.com as it appears on the list. What's REALLY strange is that I tested the <%EmailAddress%> token on the custom display as just another field, no href code, but it doesn't show on screen that way either, which is even odder.
Here's the current code as an email link:
<%First_Name%> <%Last_Name%> Ext. <%Extension%><br>
<%Job_Title%><br><br>
Is there something funky about using an email field/code in Custom Displays? Using the generic show fields tab, it shows up uneventfully. Something else? Or can you not use "live" tags in the display at all? But then why didn't it show up as a text field? I was under the impression that you could use pretty much any simple html code in the custom displays. No?
I figgered it out. Turns out the field names are <%CaSe Sensitive%>. Who knew? Works like a champ now. Is that documented anywhere, btw? Just wondering.