我有以下代碼發送Outlook郵件。但是,當前景關閉時,這不起作用。
Sub DraftMail(emailAddr, strBody, strSub)
從excel發送outlook郵件vba
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = GetObject(, "Outlook.Application")
If OutApp Is Nothing Then
Set OutApp = CreateObject("Outlook.Application")
End If Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = emailAddr
.Subject = strSub
.HTMLBody = strBody
.Send 'or use .Display
.ReadReceiptRequested = True
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
任何人可以幫助我如何使它甚至工作時的前景被關閉?
桑托斯感謝您的答覆。 但我只需要通過Outlook發送郵件。 您能否修改我的代碼以使其工作 – Tjs
@Tjs您需要輸入服務器詳細信息,更改爲,從電子郵件ID&希望它應該工作,即使對於Outlook。 – Santosh