Zum Inhalt springen

VB.NET: Aus einem Prg über Outlook Email versenden


Empfohlene Beiträge

Geschrieben

Moin,

ich hätte da mal gerne ein Problem:

Ich würde gerne aus einer Applikation (Windows Form) heraus Outlook ansprechen und eine Mail versenden. Hat jemand eine Idee, wie man das am klügsten anstellt?

Ich scheiter da schon an dem Verweis :(

Geschrieben

hi,

du brauchst den outlook verweis (verweis hinzufügen -> com -> Microsoft Outlook 11.0 Object Library (falls outlook 2003) oder Microsoft Outlook 10.0 Object Library (falls outlook 2002))

evtl. brauchst du den office verweis auch noch, ich hab den noch mit drin bin mir aber net 100% sicher ob er unbedingt erforderlich ist glaub aber schon, is schon ne zeitlang her *gg*


Public Function startOutlook(ByVal toVal As String, ByVal subjectVal As String, ByVal bodyVal As String)

        'Return a reference to the MAPI layer

        Dim ol As New Outlook.Application()

        Dim ns As Outlook.NameSpace

        Dim fdMail As Outlook.MAPIFolder


        ns = ol.GetNamespace("MAPI")


        'Logs on the user

        'Profile: This is a string value that indicates what MAPI profile to use for logging on. Leave blank if using the currently logged on user, or set to an empty string ("") if you wish to use the default Outlook Profile. 

        'Password: The password for the indicated profile. Leave blank if using the currently logged on user, or set to an empty string ("") if you wish to use the default Outlook Profile password. 

        'ShowDialog: Set to True to display the Outlook Profile dialog box. 

        'NewSession: Set to True to start a new session. Set to False to use the current session. 

        ns.Logon(, , True, True)


        'create a new MailItem object

        Dim newMail As Outlook.MailItem


        'gets defaultfolder for my Outlook Outbox

        fdMail = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox)


        'assign values to the newMail MailItem

        newMail = fdMail.Items.Add(Outlook.OlItemType.olMailItem)

        newMail.Subject = subjectVal

        newMail.Body = bodyVal

        newMail.To = toVal

        newMail.SaveSentMessageFolder = fdMail



        'adds it to the draft box

        'newMail.Save()


        'adds it to the outbox

        newMail.Send()



    End Function

bye

True

Erstelle ein Benutzerkonto oder melde Dich an, um zu kommentieren

Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde Dich hier an.

Jetzt anmelden

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...