Outlook Email Inhalt

  • Outlook

Es gibt 11 Antworten in diesem Thema. Der letzte Beitrag () ist von TheFalcon.

    Outlook Email Inhalt

    Hallo zusammen,

    ich habe folgenden Code, der fast funktioniert. Habe ein HTA Programm geschrieben. Das "Subject" wird passend angezeigt. (ausgelesen aus der comboParts.value)
    Aber der Inhalt der Email der sich aus den Variablen (txtBeschreibung, txtAuswahl, txtAuswahl1) ergebn soll wird mit Fehlern abgebrochen. Was habe ich falsch gemacht?

    Gruß TheFalcon

    Quellcode

    1. Set MyOutApp = CreateObject("Outlook.Application")
    2. Set MyMessage = MyOutApp.CreateItem(0)
    3. With MyMessage
    4. .To = "deineemail@adresse.net"
    5. .Subject = comboParts.value
    6. .body = & txtBeschreibung & vbNewLine & vbNewLine & "Dringlichkeit: " & txtAuswahl & vbNewLine & vbNewLine & "Grund: " & txtAuswahl1 & vbNewLine & vbNewLine
    7. .Display
    8. .send
    9. End With
    10. ' Mail senden und Hinweis
    11. Set MyOutApp = Nothing
    12. Set MyMessage = Nothing
    13. MsgBox "Email wurde versand"

    TheFalcon schrieb:

    .body = & txtBeschreibung & vbNewLine & vbNewLine & "Dringlichkeit: " & txtAuswahl & vbNewLine & vbNewLine & "Grund: " & txtAuswahl1 & vbNewLine & vbNewLine


    Jau, du hast da ja auch ".body = & " stehen. Mach das "&" mal Weg. :rolleyes:

    Und schau mal auf meine Signatur. :thumbsup:
    Option Strict On!

    Drahuverar schrieb:

    TheFalcon schrieb:

    .body = & txtBeschreibung & vbNewLine & vbNewLine & "Dringlichkeit: " & txtAuswahl & vbNewLine & vbNewLine & "Grund: " & txtAuswahl1 & vbNewLine & vbNewLine


    Jau, du hast da ja auch ".body = & " stehen. Mach das "&" mal Weg. :rolleyes:

    Und schau mal auf meine Signatur. :thumbsup:


    Oh hatte noch etwas vergessen, bei Lotus Notes ging es mit:

    Call notesrtf.appendtext("Fehlteil: " & txtBeschreibung & vbNewLine & vbNewLine & "Dringlichkeit: " & txtAuswahl & vbNewLine & vbNewLine & "Grund: " & txtAuswahl1 & vbNewLine & vbNewLine)
    bei Outlook scheint es aber nicht so zu funktionieren, habe die "&" weg gelassen, aber scheinbar falsch. (Bin noch nicht so erfahren in VBA)

    In der Email sollte stehen:

    Fehlteil: "txtBeschreibung"

    Dringlichkeit: "txtAuswahl"

    Grund: "txtAuswahl1"
    Ja, dann musst du deinem Programm auch sagen, dass du den Text deiner Textbox haben möchtest.

    Das wäre also:

    VB.NET-Quellcode

    1. Dim MeineVariable = txtbeschreibung.Text
    2. Dim sMeineVariable As String = txtbeschreibung.Text 'Geht auch
    3. 'Oder halt: ...
    4. .body = txtbeschreibung.Text
    5. 'Mit neuer Zeile wäre
    6. .body = txtbeschreibung.Text & Environment.Newline


    und mach in deine erste Zeile (gaaaanz oben, über der Klasse) noch

    VB.NET-Quellcode

    1. Option Strict On

    Dann zeigt Visual Studio direkt das Problemchen.
    Option Strict On!
    Vielen Dank für die schnellen Antworten, ich habe hir mal den kompletten Code vielleicht kann man da den Fehler erkennen.

    Quellcode

    1. </head>
    2. <script language="VBScript">
    3. Dim txtBeschreibung
    4. Dim txtAuswahl
    5. Dim txtAuswahl1
    6. Sub Window_OnLoad
    7. window.resizeTo 270,470
    8. End Sub
    9. Sub OnClickButtonbtnOK()
    10. txtBeschreibung = txtFehlt.Value
    11. txtAuswahl = GetAuswahlRadioValue()
    12. txtAuswahl1 = GetAuswahl1RadioValue()
    13. if txtAuswahl = "" or txtAuswahl1 = "" or txtBeschreibung = "" or comboParts.value = "" then
    14. msgbox "Es sind nicht alle Felder ausgefüllt"
    15. else
    16. SMSmatalarm
    17. Window.Close
    18. End if
    19. End Sub
    20. Function GetAuswahlRadioValue()
    21. For i=0 to Auswahl.length-1
    22. If Auswahl.Item(i).Checked Then
    23. GetAuswahlRadioValue = Auswahl.Item(i).Value
    24. Exit Function
    25. End If
    26. Next
    27. GetAuswahlRadioValue = ""
    28. End Function
    29. Function GetAuswahl1RadioValue()
    30. For i=0 to Auswahl1.length-1
    31. If Auswahl1.Item(i).Checked Then
    32. GetAuswahl1RadioValue = Auswahl1.Item(i).Value
    33. Exit Function
    34. End If
    35. Next
    36. GetAuswahl1RadioValue = ""
    37. End Function
    38. Sub SMSmatalarm()
    39. Dim strSupportEMail
    40. Set MyOutApp = CreateObject("Outlook.Application")
    41. Set MyMessage = MyOutApp.CreateItem(0)
    42. With MyMessage
    43. .To = "maxmustermann"
    44. .Subject = comboParts.value
    45. .body = txtbeschreibung & Environment.Newline & txtAuswahl & Environment.Newline & txtAuswahl1
    46. .send
    47. End With
    48. ' Mail senden und Hinweis
    49. Set MyOutApp = Nothing
    50. Set MyMessage = Nothing
    51. MsgBox "Vorfertigung wurden informiert"
    52. End Sub
    53. </script>
    54. <body bgcolor="#ADD8E6">
    55. <div style="margin:10px auto; text-align: center">
    56. <h3 style="font-size:12pt; align="center"; margin-bottom:0">M-Alarm Endmontage</h3>
    57. <p><span style="font-size:12pt"><strong><u>Teamsprecher</u></strong></span><br/>
    58. <select name="comboParts" id="comboParts">
    59. <option value=""></option>
    60. <option value="Alarm Team 1">Team 1</option>
    61. <option value="Alarm Team 2">Team 2</option>
    62. </select>
    63. <p><span style="font-size:12pt"><strong><u>Was fehlt?</u></strong></span><br/>
    64. <span style="font-size:10pt">(Problem)</span>
    65. <input type="text" name="txtFehlt" id="txtFehlt" style="width:80%"></p>
    66. <p><span style="font-size:12pt"><strong><u>Wie dringend?</u></strong></span><br/>
    67. <input type="radio" name="Auswahl" value="Sofort">Sofort<BR>
    68. <input type="radio" name="Auswahl" value="Später">Später<BR>
    69. <span style="font-size:12pt"><strong><u>Warum fehlt es?</u></strong></span><BR>
    70. <input type="radio" name="Auswahl1" value="Defekt">Defekt<BR>
    71. <input type="radio" name="Auswahl1" value="Vergessen">Vergessen zu bestellen<BR>
    72. <div style="margin:10px auto; text-align: center"><input type="button" name="btnOK" id="btnOK" value="Alarm auslösen" onclick="OnClickButtonbtnOK"></div>
    73. <h3 style="font-size:8pt; margin-bottom:0"></h3>
    74. </body>
    75. </html>
    Ja das stimmt, hatte mich vertan ;( habe jetzt auch mein Problem gefunden

    Quellcode

    1. Set MyOutApp = CreateObject("Outlook.Application")
    2. Set MyMessage = MyOutApp.CreateItem(0)
    3. With MyMessage
    4. .To = "maxmuster@goo.com"
    5. .Subject = comboParts.value
    6. .body = txtbeschreibung & vbNewLine & vbNewLine & txtAuswahl & vbNewLine & vbNewLine & txtAuswahl1
    7. .send
    8. End With


    Es läuft jetzt !!!

    Wie kann ich jetzt noch die Bezeichnung einfügen vor der Beschreibung? Das ausgegeben wird:

    Beschreibung: (Inhalt von txtBeschreibung)




    Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von „TheFalcon“ ()