English 中文(简体)
VBA, Excel,《展望》闭门时寄送电子邮件
原标题:Sending Email with attachment by MS-Outlook in VBA, Excel when Outlook is closed

当我免费寄出邮件时,我确实工作。

但在我使用<代码>时。 附文。 添加《积极工作手册》。

www.un.org/Depts/DGACM/index_spanish.htm 当展望结束时,我想寄出邮件。

I m 采用以下代码:

Sub SendMail()
    Dim OutlookApp As Outlook.Application
    Dim OutlookMail As Outlook.MailItem

    Set OutlookApp = New Outlook.Application
    Set OutlookMail = OutlookApp.CreateItem(olMailItem)

    With OutlookMail
        .To = "[email protected]"
        .CC = ""
        .BCC = ""
        .Subject = "M"
        .BodyFormat = olFormatHTML
        .HTMLBody = "Hi, <p> I m sending this message from Excel using VBA.</p>Please find <strong> M</strong> in life."
        .Attachments.Add ActiveWorkbook.FullName
        .DeferredDeliveryTime = DateAdd("n", 1, Now)
        .Importance = olImportanceHigh
        .ReadReceiptRequested = True
        .Send
    End With
    Set OutlookMail = Nothing
    Set OutlookApp = Nothing
End Sub

<代码>。 推迟提交日期=Add(n),1,现在,: 我希望,电子邮件在管理宏观后发出1分钟。

在这方面。

这个问题为何独特:

  1. StackowerflowQuestion: Here the problem is solved in my above code and the remained problem is sending attachment that I focused on here. and the appropriated answer is what I accent about is Outlook is closed.

Update

另一种症状是,在我手法上,一个时间的Icon将展示在传感的审理系统中: 另一种方案正在使用展望。 a. 脱节方案与退出前景。

还请考虑这一点,如果重要的话。


请注意,问题在于 附文

根据上述准则,在前景结束时发送电子邮件的问题已经解决。 (在类似问题中提及)

因此,目前的问题是 随函附上<>/strong>(截止)。

问题回答

Sorry, I misinterpreted your question just now. With reference to here, you need to add the following code.

Dim OutApp As Outlook.Application 
Dim OutMail As Outlook.MailItem

On Error Resume Next 
Set OutApp = GetObject(, "Outlook.Application") 
If OutApp Is Nothing Then 
    Set OutApp = CreateObject("Outlook.Application") 
End If 
On Error Goto 0 

Set OutMail = OutApp.CreateItem(olMailItem) 
With OutMail 
    .To = "[email protected]"   continue from here




相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...