當我激活此宏時,是否有辦法從已登錄的Outlook帳戶「讀取」用戶電子郵件地址併發送電子郵件?從發件人帳戶獲取電子郵件地址
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 = "[email protected]"
.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
我需要獲取「from」電子郵件地址。
EDIT1方案:針對SMTP
Msgbox
CreateObject("Outlook.Application").GetNamespace("MAPI").Session.CurrentUser. _
AddressEntry.GetExchangeUser.PrimarySmtpAddress