Worum geht’s?
Du bekommst englische, französische oder polnische Mails.
Du sollst schnell antworten – in gutem Business-Deutsch.
Oder umgekehrt. Du willst Deine Mail ins Englische bringen.
Jede Übersetzung kostet Zeit.
Also machen wir’s per API.
Direkt aus Outlook. Mit VBA.
Was brauchst Du?
- Outlook Classic (kein Web)
- Zugriff auf den VBA-Editor
- Einen API-Key von DeepL oder Google
- Etwas Geduld für Debugging
Was wird übersetzt?
- Der Inhalt der aktuellen Mail (eingehend)
- Oder Deine Antwort (ausgehend)
- Je nach Wunsch: nur Body oder inkl. Betreff
DeepL vs Google
Anbieter | Vorteile | Nachteile |
---|---|---|
DeepL | Sehr gute Sprachqualität | Begrenzte kostenlose Nutzung |
Mehr Sprachen, schneller | Formaler, weniger nuanciert |
Ich zeig Dir beide Varianten.
Variante 1: DeepL per VBA
DeepL API aufrufen
Function DeepLTranslate(text As String, fromLang As String, toLang As String) As String
Dim http As Object
Dim result As String
Dim apiKey As String
Dim url As String
Dim body As String
apiKey = "deepl-api-key" ' Dein DeepL API-Key
url = "https://api-free.deepl.com/v2/translate"
body = "auth_key=" & apiKey & _
"&text=" & URLEncode(text) & _
"&source_lang=" & UCase(fromLang) & _
"&target_lang=" & UCase(toLang)
Set http = CreateObject("MSXML2.XMLHTTP")
With http
.Open "POST", url, False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send body
result = .responseText
End With
Dim startPos As Long, endPos As Long
startPos = InStr(result, """text"":""") + 8
endPos = InStr(startPos, result, """}")
DeepLTranslate = Mid(result, startPos, endPos - startPos)
End Function
URL-Encoding-Helfer
Function URLEncode(str As String) As String
str = Replace(str, " ", "%20")
str = Replace(str, vbCrLf, "%0A")
str = Replace(str, vbLf, "%0A")
URLEncode = str
End Function
Variante 2: Google Translate per Web-Scraping
Google Translate hat keine offizielle kostenlose API.
Aber per URL-Trick geht’s – zumindest testweise.
Function GoogleTranslate(text As String, fromLang As String, toLang As String) As String
Dim http As Object
Dim url As String
Dim result As String
Dim decoded As String
url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" & _
fromLang & "&tl=" & toLang & "&dt=t&q=" & URLEncode(text)
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", url, False
http.send
result = http.responseText
decoded = Mid(result, 5, InStr(result, """,""") - 5)
GoogleTranslate = decoded
End Function
Anwendung in Outlook
Eingehende Mail übersetzen
Sub UebersetzeAktuelleMail()
Dim mail As MailItem
Dim body As String
Dim output As String
Set mail = Application.ActiveExplorer.Selection.Item(1)
body = mail.Body
output = DeepLTranslate(body, "EN", "DE") ' Oder GoogleTranslate
MsgBox output, vbInformation, "Übersetzte Mail"
End Sub
Antwort auf Deutsch in Englisch übersetzen
Sub AntwortUebersetzenUndEinfügen()
Dim reply As MailItem
Dim original As MailItem
Dim text As String
Dim translated As String
Set original = Application.ActiveExplorer.Selection.Item(1)
Set reply = original.Reply
text = InputBox("Was willst Du antworten?", "Antwort auf Deutsch")
translated = DeepLTranslate(text, "DE", "EN")
reply.Body = translated & vbCrLf & vbCrLf & reply.Body
reply.Display
End Sub
Was Du beachten solltest
- Zeichenlimit bei DeepL Free: 500.000/Monat
- Google kann kurzfristig blocken (kein offizieller Support)
- HTML-Mails? Erst
MailItem.BodyFormat = olFormatPlain
prüfen - Nutzungsbedingungen beachten
Erweiterungsideen
- Übersetzung von HTML-Mails mit BodyHTML
- Sprachauswahl per Dropdown
- Automatische Erkennung der Ausgangssprache
- Batch-Verarbeitung kompletter Postfächer
Wenn Du öfter Mails in anderen Sprachen brauchst – bau Dir die Übersetzung direkt in Outlook ein und spar Dir das Browser-Gehampel.
Keine Antworten