Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo und guten Abend,

erstmals stehe ich vor einem VBA Problem und suche hier - hoffentlich erfolgreich - Hilfe.

Ich möchte mit einem VBA-Script eine Mail an Outlook zur weiteren Bearbeitung übergeben. Bis auf die Übergabe der Absender-EMailadresse funktioniert alles. Hier mein Script:

    Dim objOutlook As Outlook.Application
    Dim objMail As Outlook.MailItem
    Dim objAccount As Outlook.Account

    Set objOutlook = New Outlook.Application
    Set objMail = objOutlook.CreateItem(olMailItem)

    With objMail
        .objAccount = Me.Absender                        ' Fehler 438 Objekt unterstützt diese Eigenschaft oder Methode nicht
        .Recipients.ADD Empfaenger(0)
        If Empfaenger(1) <> "" Then .CC = Empfaenger(1)
        If Empfaenger(2) <> "" Then .BCC = Empfaenger(2)
        .Subject = Me.Subject
        .BodyFormat = olFormatHTML
        .HTMLBody = Me.Mail
        .Display
    End With

An der Rot-markierten Stelle kommt der Fehler 438 und ich weiß mir keinen Rat. In Me.Absender steht die EMail-Absenderadresse als String.

Vielleicht hat ja schon jemand dieses Problem gelöst - hoffe ich - und kann mir helfen?

Vielen Dank im Voraus.

Axel Korte

Hallo,

ich kenne mich mit VBA nicht aus, aber du erstellst objAccount ja als eigenes Objekt und versuchst dieses dann als Methode bzw. Eigenschaft von deinem Objekt objMail aufzurufen, wenn ich das richtig sehe. Aber objMail hat ja so gesehen erst einmal keine Verbindung mit objAccount und schon gar nicht als Eigenschaft bzw. Methode.

  • Autor

Danke für Deine Whiz-zarD Antwort. SenderEmailAddresse ist ein schreibgeschütztes Argument und daher ungeeignet.

Danke auch für die Anworten von Rienne und Gottlike. Ich verstehe was Sie meinen und versuche das morgen umzusetzen.

Bearbeitet von Axel.Korte

  • Autor

Guten Abend,

ich habe, dank Ihrer aller Hilfe das Problem lösen können. Hier der korrekte Code, falls jemand auf ein ähnliches Problem stößt:

Dim objOutlook As Outlook.Application
Dim objMail As Outlook.MailItem
Dim objAccount As Outlook.Account

Set objOutlook = New Outlook.Application
Set objMail = objOutlook.CreateItem(olMailItem)

If Me.Absender <> "" Then
    For Each objAccount In objOutlook.Session.Accounts
        If objAccount.DisplayName = Me.Absender Then Exit For
        Set objAccount = Nothing
    Next objAccount
Else
    Set objAccount = Nothing
End If

With objMail
    If Not objAccount Is Nothing Then
        .SendUsingAccount = objAccount
    Else
        MsgBox "Account ''" &  Absender & "'' nicht gefunden.", vbCritical, "Hinweis"
    End If

    .Recipients.ADD Empfaenger(0)

    If Empfaenger(1) <> "" Then .CC = Empfaenger(1)
    If Empfaenger(2) <> "" Then .BCC = Empfaenger(2)

    .Subject = Me.Subject
    .BodyFormat = olFormatHTML
    .HTMLBody = Me.Mail
    .Display
End With
Interessant ist dabei, dass in .SendUsingAccout nicht die EMail-Adresse sondern die Bezeichnung des Kontos im Outlook steht.

 

Vielen Dank nochmals und eine besinnliche Weihnachtszeit.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.