Solved

Translate to english a received email

Posted on 2009-05-15
5
340 Views
Last Modified: 2013-11-27
Hi Guys

I have a site that is sending me emails in spanish, is there any way that i can create a rule that as soon as i receive an email from this sender, translate that email to english

Please advice
0
Comment
Question by:titorober23
5 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
titorober23,

<is there any way that i can create a rule that as soon as i receive an email from this sender, translate that email to english>
Sorry, No.
Most Outlook "rules" will specify what happens to an email, not manipulate what is inside of it.
Although you can specify Outlook to look at keywords in an email, I don't think there is an easy way for Outlook to "detect" the language, then translate the text in the body of the email.

However, a user at my company uses this product:
http://www.desktoptranslator.com/default-b.asp?linkID=1

It will translate the email once opened, thus achieving your ultimate goal of translating the email from spanish to english.

;-)

JeffCoachman
0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
Just don't expect miracles with the translation.  Sometimes the results can be unintentionally hilarious.
0
 
LVL 76

Expert Comment

by:David Lee
Comment Utility
Hi, titorober23.

It is possible to translate a message using Google's translation API and a bit of scripting.  The output will be strictly plain-text though and some other formatting (e.g. carriage returns) will be lost.  I've only tested it with fairly short messages, so I don't know how it'll do if the message is very long.  I'll post the code if you're interested.

Another alternative is to use Outlook's built-in translation capability.  To use it

1.  Select the text you want to translate.
2.  Right-click and select Translate > Translate.
3.  Select the From and To languages.
0
 

Author Comment

by:titorober23
Comment Utility
BlueDevilFan

Can you please post the code
0
 
LVL 76

Accepted Solution

by:
David Lee earned 300 total points
Comment Utility
Sure.  Here it is.  Follow these instructions to use it.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects
4.  If not already expanded, expand Modules
5.  Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
6.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
7.  Edit the code as needed.  I included comments wherever something needs to or can change
8.  Click the diskette icon on the toolbar to save the changes
9.  Close the VB Editor
10. Create a rule that fires for these messages
11. Set the rule's action to "run a script" and select TranslateMessage as the script to run.

Here's how this works.

1.  When a message arrives Outlook runs rules.
2.  If the rule created in step 10 evaluates to true, then Outlook runs the script
3.  TranslateMessage calls te second script TranslateText
4.  TranslateText passes the message body to Google's language API asking it to translate from Spanish to English
5.  Google translates the message body and returns the Spanish text
6.  TranslateText returns the text to TranslateMessage which inserts it back into the original message

I don't have any messages in Spanish, so I tested by translating from English to Spanish.  It worked fine.  As noted above I don't know if there's a limit on the length of text that Google will translate.  

If you are interested in Google's language API visit: http://code.google.com/apis/ajaxlanguage/documentation/
Sub TranslateMessage(Item As Outlook.MailItem)

    Item.Body = "---- Translation ----" & vbCrLf & TranslateText(Item.Body) & vbCrLf & "---- End Translation ----" & vbCrLf & vbCrLf & Item.Body

    Item.Save

End Sub
 

Function TranslateText(strText As String) As String

    Dim objXMLHTTP As Object

    Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")

    With objXMLHTTP

        .Open "GET", "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=" & Replace(strText, " ", "%20") & "&langpair=es%7Cen", False

        'Change the referer as desired.  This is a fake URL.'

        .setRequestHeader "REFERER", "http://www.mysite.com/index.html"

        .Send

        Do Until .readyState = 4

            DoEvents

        Loop

        intStart = InStr(1, .responseText, "translatedText")

        intEnd = InStr(intStart, .responseText, "}")

        TranslateText = Mid(.responseText, intStart + 17, (intEnd - 1) - (intStart + 17))

    End With

    Set objXMLHTTP = Nothing

End Function

Open in new window

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Granting full access permission allows users to access mailboxes present in their database. By giving full access permission one can open and read the content of any mailbox but cannot send emails from that mailbox.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now