How do I use the Outlook Object Model to set the encoding for a single outbound email? - vba

I am using the Outlook object model to send messaegs and some have Japanese characters. The recipient receives them as letters and numbers so I'd like to send these messages using utf-8 encoding. I can configure this for all messages in Outlook Advanced options but would prefer not to change that setting whenever I need to do this (I leave at Western European ISO normally).
How do I create a message and set the encoding? I tried using the InternetCodePage value but that didn't work. The value would be set to 65001 as shown below but as soon as I set the htmlbody property, the value would change to ASCII.
I'm using PowerShell and welcome ideas.
$Mail = $Outlook.CreateItem(0)
$mail.InternetCodepage = "65001"
$Mail.HTMLBody = $HTMLWithJapaneseCharacters

Instead of relying on the right code page for the whole email, all Unicode characters inside the HTML body must be HTML-encoded.

Related

Display markdown safely as HTML in Vue3

So I have a set of strings, with some "custom markdown" that I have created. My intention is to render these strings as HTML in the frontend. Let's say, I have this string:
This is a string <color>that I need</color> to\nrender <caution>safely in the browser</caution>. This is some trailing text
I would be expecting to get something like:
This is a string <span class="primaryColor">that I need</span> to<br>render <div class="caution">safely in the browser</div>. This is some trailing text
And the way I do it right now is with some basic Regex:
toHtml = text
.replace(/<color>(.*)<\/color>/gim, "<span class='primaryColor'>$1</span>")
.replace(/\\n/g, "<br>")
.replace(/<caution>(.*)<\/caution>/gims, "<div class='caution'>$1</div>")
This works fine and returns the correct string. And then for printing, in the template I just:
<div id="container" v-html="result"></div>
My problem is that at some point I expect users to be able to enter this strings themselves, and that would be displayed to other users too. So for sure, I am gonna be vulnerable to XSS attacks.
Is there any alternative I can use to avoid this? I have been looking at https://github.com/Vannsl/vue-3-sanitize which looks like a good way of just allowing the div, span and br tags that I am using, and set the allowed attributes to be only class for all the tags. Would this be safe enough? Is there something else I should do?
In that case, I believe it will not be necessary to sanitize it in the backend too, right? Meaning, there will be no way for the web browser to execut malicious code, even if the string in the server contains <script>malicious code</script>, right?
My problem is that at some point I expect users to be able to enter this strings themselves
So, Do we have a form input for the users to enter the string which you mentioned in the post ? If Yes, My suggestion is that you can sanitize the user input at first place before passing to the backend. So that in backend itself no malicious code should be stored.
Hence, By using string.replace() method. You can first replace the malicious tags for ex. <script>, <a, etc. from the input string and then store that in a database.
Steps you can follow :
Create a blacklist variable which will contain the regex of non-allowed characters/strings.
By using string.replace(), replace all the occurrence of the characters available in the string as per the blacklist regex with the empty string.
Store the sanitized string in database.
So that, You will not get worried about the string coming from backend and you can bind that via v-html without any harm.

How to read RFC822 content as plain text?

First thing to note...I have tried a simple doc.computewithform(false,false) and it did not resolve this.
I have an agent set to run after new mail arrives. This agent will do different things depending on the email address it was sent to. Several email addresses are pointed to this mail-in db. So, in order for this to work, I need to read the 'sendto' field on the incoming email. Sometimes this value is plain text, and that works fine. Sometimes, depending on where the email was initiated, the sendto value is RFC822 text. I am hoping to find a way to convert this or extract from it the plain text representation of the sendto address.
I have a local memo form in this database that I could add an #Formula language function to, should one exist (so I could look there after the computewithform call).
If anyone has any ideas, I would be grateful for your input.
Matt
#Name([Abbreviate];SendTo) will extract the text from a field of RFC822 type 'Address'
or
The NotesName class in LotusScript can retrieve any part of a field of type 'RFC822 Text'

How to remove inbound attachments from message property?

I m using a html form which allows user to enter the details and choose a file to be sent as an attachment with an email via smtp connector in mule. I m using encoding type as- enctype="multipart/form-data" in my html form with method as "post". So all my html fields are coming as inbound attachments and they are being sent as separate 8 attachments in the mail.
Out of the 8 inbound attachments i want to drop 7 attachments and send only one attachment that is the file (highlighted with green) via email. How can i achieve this? Which transformer i should use?
[mule message structure image][1]
![1]: http://i.stack.imgur.com/F9fYu.png
I had similar problem and I found solution. First, you need to copy interesting attachment from inbound to outbound (use copy-attachment tag) and after that you should use transformer email:object-to-mime-transformer with attribute useInboundAttachments set to false. Works for me.
According to me you can drag and drop Attachment transformer after you receive all the attachments and then select Copy Attachment and give value as #[message.inboundAttachments.'file'].
Same to remove you can drag and drop Attachment Transformer and then select RemoveAttchment and then using MEL give attachment name.
#[message.inboundAttachments.'subject']
Hope this helps you !

facebook api query string issue

I develop a facebook api with asp.net , I have to send query string but this querystring may include special characters like ( ı, ç ö, ş, ğ ). When I send query string with special characters, facebook returns me an error-
The URL http://apps.facebook.com/sportsfanarena/Results.aspx?s=13&co=3&ci=Bal%c4%b1kesir&g=0 is not valid.
The "ci" variable's value is "Balıkesir".
Is there any solution to handle it?
I believe you need to use URL encoding to send characters like that, though I may be mistaken.
Here is an online utility which will take text and encode/decode it in URL encoding.
Try encoding the word you are wanting to send using this utility, and then try your API request with the encoded text.

Handle UTF-8 DataString ( Velocity/Struts )

Hey guys, lately, I use the combination of Struts and Velocity frameworks to create some website, the problem is that when I tried to input UTF-8 Japanese character, say, a field name, which I putted in the value of "索", then I click submit ( using ), the data would be passed to an AddForm, which I have the String name field to handle the name field. Problem is that, the received string is some strange letter than the expected string "索", I set all the workspace to UTF-8, in velocity.property ( input.coding/outputcoding = UTF-8 ), content-type/charset = UTF-8, but it always returns strange string, I could set the name field directly with : public void setName(String name) { this.name = "索" } and the confirm Add work fine, but not with normally insert it to name field on the addForm, someone could point me out what was wrong ? Thanks for patient reading :D.
I understood your problems is as follows, is this right?
you can send and display “索” correctly on client browsers,
but when the form is sent back to server, data is corrupted.
This is caused by mismatch between:
encoding in which the request is encoded (UTF-8 as you said) and
encoding by which the server decodes (ISO-8859-1 by default).
It can be solved by specifying server-side encoding (2nd of above) explicitly using CharacterEncodingFilter of Spring Framework.
(note: Japanese frameworks such as Seasar and TERASOLUNA have similar filter and articles on the problem.)