簡體   English   中英

使用單元格中的excel信息從Outlook自動發送電子郵件

[英]Auto Email Send from outlook using excel information from the cell

在此處輸入圖片說明

我需要使用Excel Outlook從Excel發送自動電子郵件,我正在嘗試編碼但無法執行。 我已附上表格供您參考。

Sub SendEmail()

Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

With OutMail
    .To = "ABC@gmail.com"
    .CC = ""
    .BCC = ""
    .Subject = "Report"
    .Body = "Hello!"
    .Attachments.Add ActiveWorkbook.FullName

    .Send
End With

Set OutMail = Nothing
Set OutApp = Nothing
Application.OnTime TimeValue("17:00:00"), "SendEmail"

End Sub

在創建電子郵件之前,您將需要引用並登錄到Outlook.Namespace。

嘗試將其添加到您的代碼中:

Set OutApp = CreateObject("Outlook.Application")

'** -> add this block here
Dim OutNS as Object
Set OutNS = OutApp.GetNamespace("MAPI")
OutNS.Logon
'**

Set OutMail = OutApp.CreateItem(0)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM