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.

eMail mit Visual Basic

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

ich möchte aus Visual Basic heraus eine eMail an den Standard eMailClient des Benutzers schicken.

Bis jetzt benutze ich dazu die "ShellExecute" mit "mailto:" .....

Das Problem ist das an die eMail direkt eine Datei (Pfad ist bekannt) angehängt werden soll.

Als Ergebnis soll sich der eMailClient öffnen, es soll eine neue eMail geöffnet werden mit Empfänger, Betreff und ganz wichtig mit ANHANG.

Bin für jede Lösung, auch mit kleinerern Umwegen dankbar.

MfG

MichaK

MOIN!

Damit arbeite ich immer, habe Dir einfach mal die ganze Funktion rauskopiert, es funzt einwandfrei!!!

Function EMail_versenden(MailAdresse As String, MailBetreff As String, MailText As String, Optional WordAttachment As String = "", Optional AttachmentDescribtion As String = "", Optional ProtectDocument As Boolean = True) As Long

Dim OutLookApp As New Outlook.Application  'Outlook Applikation

Dim OutLookNameSpace As Outlook.NameSpace  'Outlook Postfach

Dim OutLookItem As Outlook.MailItem        'Outlook Mail

Dim OutLookTempID

Dim Ergebnis As Long

Dim pMNameLogin As String

pMNameLogin = tools.MNameSetzen

Ergebnis = 0

On Error GoTo ErrorHandeler_Mail

    Set OutLookNameSpace = OutLookApp.GetNamespace("MAPI")

    OutLookTempID = OutLookApp.Application.Session

    If ProtectDocument And WordAttachment <> "" Then

        Ergebnis = tools.WordDocSchützen(WordAttachment)

        If Ergebnis = 0 Or Ergebnis = 4605 Then

        Ergebnis = 0

        Else

            MsgBox "Dokument konnte nicht geschützt werden, die Aktion wurde abgebrochen", vbOKOnly + vbCritical, "Word- Fehler"

            Exit Function

        End If

    End If


    Set OutLookItem = OutLookApp.CreateItem(olMailItem)

    With OutLookItem

        .To = MailAdresse

        .Subject = MailBetreff

        If MailText <> "" Or Not IsNull(MailText) Then

            .Body = "Anmerkung:" & vbCrLf & MailText & vbCrLf

        End If

        .Body = .Body & _

                "-----------------------------------------" & vbCrLf & _

                "Beliebiger Fußtext" & vbCrLf & vbCrLf

        If WordAttachment <> "" Then

            .Attachments.Add WordAttachment, , , AttachmentDescribtion

        End If

    End With


    OutLookItem.Send


    OutLookNameSpace.Logoff

    Outlook.Application.Quit

    EMail_versenden = Ergebnis

Exit Function


ErrorHandeler_Mail:

    Ergebnis = err.Number

    Debug.Print "Fehler: " & Ergebnis & " " & err.Description

    OutLookNameSpace.Logoff

    Outlook.Application.Quit

    Set OutLookItem = Nothing

    Set OutLookNameSpace = Nothing

    Set Outlook.Application = Nothing

    EMail_versenden = Ergebnis

End Function

MfG Arnie

Danke Arnie,

ich benötige aber eine Universelle Funktion da ich nicht davon ausgehen kann das der Benutzer Outlook verwendet zumal die meisten unserer Kunden David favoritisieren.

Hat jemand ne universelle Funktion?

also ich hab einen vbSendMail.dll die ich einfach nur weitergeben kann. Allerdings brauchst du auf jedenfall ein Mailserver über den Du senden kannst.

ansonsten ist die Dll recht einfach zu handhaben.

Guido

vbSendMail.dll

ist diese vbSendMail.dll Lizenz- und oder kostenpflichtig?

Wenn nicht, wo kann ich diese datei downloaden?

also ich denke nicht das sie etwas kostet. aber sie funktioniert ganz gut.

unter http://www.freevbcode.com kannst du sie runterladen, mit Beispiel.

Guido

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.