Is there a way to "read" the user E-Mail Address from Outlook Account which is logged in and send an E-Mail when I activate this Macro?
Sub MailSenden()
Dim olApp As Object
Dim olOldBody As String
Rem Email erstellen
Set olApp = CreateObject("Outlook.Application")
With olApp.CreateItem(0)
.GetInspector.Display
olOldBody = .htmlBody
.To = "carsten.asdf@xxx.yy"
.Subject = "Testformular"
.Body = "Das ist eine e-Mail" & Chr(13) & _
"Viele Grüße..." & Chr(13) & Chr(13)
.Attachments.Add "C:\Users\" & Environ$("USERNAME") & "\Desktop\" & "CSV-Export.csv"
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
Kill "C:\Users\" & Environ$("USERNAME") & "\Desktop\" & "CSV-Export.csv"
End Sub
I need to get the "from" E-Mail address.
EDIT1: Solution for smtp
Msgbox
CreateObject("Outlook.Application").GetNamespace("MAPI").Session.CurrentUser. _
AddressEntry.GetExchangeUser.PrimarySmtpAddress