Solved

Translate to english a received email

Posted on 2009-05-15
5
349 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24401427
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
ID: 24404302
Just don't expect miracles with the translation.  Sometimes the results can be unintentionally hilarious.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24404584
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
ID: 24417806
BlueDevilFan

Can you please post the code
0
 
LVL 76

Accepted Solution

by:
David Lee earned 300 total points
ID: 24420119
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

617 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