我需要能夠從Excel發送電子郵件,但我希望電子郵件的正文包含來自用戶窗體的值在您按下提交後。添加用戶表單輸入到電子郵件VBA代碼到電子郵件正文
我試過不同的事情,但我堅持下面的代碼。
Dim aOutlook As Object
Dim aEmail As Object
Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String
Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(0)
'set Importance
aEmail.Importance = 2
'Set Subject
aEmail.Subject = "TestMailSend"
'Set Body for mail
aEmail.Body = "Campaign Name" & Me.ComboBox5.Value
"Job Number" & Me.ComboBox4.Value
"Revenue" & Me.ComboBox3.Value
'send one off to 1 person use this static code
'aEmail.Recipients.Add "[email protected]"
aEmail.Recipients.Add "Insert email address here"
'Send Mail
aEmail.Send
什麼是真正的問題嗎?你的用戶表單中有代碼嗎?順便說一句,你應該使用'&'連接你的電子郵件正文的數據 – RCaetano
這是問題:aEmail.Body =「廣告系列名稱」Me.ComboBox5.Value 「工作號碼」Me.ComboBox4.Value 「收入」我。 ComboBox3.Value –
您是否檢查過我的答案,看它是否解決了問題? – RCaetano