.发送的不是正在工作的vba而是.display

时间:2022-08-14 18:15:06

My ".send" is not working however my ".display" is? I keep getting an object defined error. and when I debug it highlights the ".send". Any suggestions?

我的”。发“不是工作而是我”。显示”是什么?我不断地得到一个对象定义的错误。当我调试时,它会突出显示“.send”。有什么建议吗?

Sub SendEmails()

Dim olApp As Outlook.Application
Dim olMail As Outlook.MailItem

For i = 8 To 10
    Set olApp = New Outlook.Application
    Set olMail = olApp.CreateItem(olMailItem)

    With olMail
    .BCC = Cells(i, 1).Value
    .Subject = Cells(i, 2).Value
    .Body = "Hello " & Cells(i, 3).Value & "," & vbNewLine & vbNewLine & Cells(i, 4).Value & vbNewLine & vbNewLine & Cells(i, 5).Value & vbNewLine & Cells(i, 6).Value
    .Attachments.Add "H:\Shared\Public\Focus 6\Private Equity\Send Emails\2017-01-18\EY - Capitalizing on Opportunities (PE O&G).pdf"
    .Send

    End With
Next

Set olMail = Nothing
Set olApp = Nothing

End Sub

3 个解决方案

#1


1  

As @Nathan_Sav mentioned, you can probably play around with your Outlook security features. As an alternative, you can experiment with the .SendKeys function...though please note that this is not a very reliable method, especially if you are going to need other people/other machines to try and use this macro.

正如@Nathan_Sav提到的,您可以使用Outlook安全特性。作为替代方案,您可以尝试使用.SendKeys函数…尽管请注意,这不是一个非常可靠的方法,特别是如果您需要其他人/其他机器来尝试和使用这个宏。

But if you replace

但是如果你更换

.Send

With

.SendKeys "%S"

It might work for you.

可能对你有用。

#2


0  

.Display will give you a view of the email. If this step works, then .Send will work efficiently. When using .Send you will receive a message box acknowledging that a 3rd party program is trying to access outlook (If everything is configured correctly). To fix this if it is not configured, open the workbook and then open the VBE (Alt+F11). From there goto Tools-->References and uncheck any that are marked "Missing". If possible, look for the appropriate Outlook Object library and check it.

. display会给你一个电子邮件的视图。如果这个步骤有效,那么. send将有效地工作。当使用. send时,您将收到一个消息框,确认第三方程序正在尝试访问outlook(如果一切配置正确)。如果没有配置,请打开工作簿,然后打开VBE (Alt+F11)。从那里goto工具——>引用和不检查任何标记为“缺少”的。如果可能的话,查找适当的Outlook对象库并检查它。

Sub SendEmails()

Dim olApp As Outlook.Application
Dim olMail As Outlook.MailItem

For i = 8 To 10
    Set olApp = New Outlook.Application
    Set olMail = olApp.CreateItem(olMailItem)

    With olMail
    .BCC = Cells(i, 1).Value
    .Subject = Cells(i, 2).Value
    .Body = "Hello " & Cells(i, 3).Value & "," & vbNewLine & vbNewLine & Cells(i, 4).Value & vbNewLine & vbNewLine & Cells(i, 5).Value & vbNewLine & Cells(i, 6).Value
    .Attachments.Add "H:\Shared\Public\Focus 6\Private Equity\Send Emails\2017-01-18\EY - Capitalizing on Opportunities (PE O&G).pdf"
    .Display

    End With
Next

Set olMail = Nothing
Set olApp = Nothing

End Sub

#3


0  

Most organizational emails have a mandatory document/email labelling policy where you have to choose between options like public, restricted, confidential, etc. If your outlook is setup so that you must choose one of these options before sending the email, this might be the reason for getting an error. There aren't many solutions that I know of for this issue, other than deactivating the plugin that requires you to label emails before sending them. But maybe someone else may have other suggestions.

大多数组织电子邮件都有一个强制性的文件/电子邮件标签政策,你必须在公共、限制、机密等选项之间进行选择。如果你的outlook是设置的,所以你必须在发送电子邮件之前选择其中一个选项,这可能是导致错误的原因。对于这个问题,我所知道的解决方案并不多,除了停用插件外,这个插件要求你在发送电子邮件之前给邮件贴上标签。但是也许其他人有其他的建议。

#1


1  

As @Nathan_Sav mentioned, you can probably play around with your Outlook security features. As an alternative, you can experiment with the .SendKeys function...though please note that this is not a very reliable method, especially if you are going to need other people/other machines to try and use this macro.

正如@Nathan_Sav提到的,您可以使用Outlook安全特性。作为替代方案,您可以尝试使用.SendKeys函数…尽管请注意,这不是一个非常可靠的方法,特别是如果您需要其他人/其他机器来尝试和使用这个宏。

But if you replace

但是如果你更换

.Send

With

.SendKeys "%S"

It might work for you.

可能对你有用。

#2


0  

.Display will give you a view of the email. If this step works, then .Send will work efficiently. When using .Send you will receive a message box acknowledging that a 3rd party program is trying to access outlook (If everything is configured correctly). To fix this if it is not configured, open the workbook and then open the VBE (Alt+F11). From there goto Tools-->References and uncheck any that are marked "Missing". If possible, look for the appropriate Outlook Object library and check it.

. display会给你一个电子邮件的视图。如果这个步骤有效,那么. send将有效地工作。当使用. send时,您将收到一个消息框,确认第三方程序正在尝试访问outlook(如果一切配置正确)。如果没有配置,请打开工作簿,然后打开VBE (Alt+F11)。从那里goto工具——>引用和不检查任何标记为“缺少”的。如果可能的话,查找适当的Outlook对象库并检查它。

Sub SendEmails()

Dim olApp As Outlook.Application
Dim olMail As Outlook.MailItem

For i = 8 To 10
    Set olApp = New Outlook.Application
    Set olMail = olApp.CreateItem(olMailItem)

    With olMail
    .BCC = Cells(i, 1).Value
    .Subject = Cells(i, 2).Value
    .Body = "Hello " & Cells(i, 3).Value & "," & vbNewLine & vbNewLine & Cells(i, 4).Value & vbNewLine & vbNewLine & Cells(i, 5).Value & vbNewLine & Cells(i, 6).Value
    .Attachments.Add "H:\Shared\Public\Focus 6\Private Equity\Send Emails\2017-01-18\EY - Capitalizing on Opportunities (PE O&G).pdf"
    .Display

    End With
Next

Set olMail = Nothing
Set olApp = Nothing

End Sub

#3


0  

Most organizational emails have a mandatory document/email labelling policy where you have to choose between options like public, restricted, confidential, etc. If your outlook is setup so that you must choose one of these options before sending the email, this might be the reason for getting an error. There aren't many solutions that I know of for this issue, other than deactivating the plugin that requires you to label emails before sending them. But maybe someone else may have other suggestions.

大多数组织电子邮件都有一个强制性的文件/电子邮件标签政策,你必须在公共、限制、机密等选项之间进行选择。如果你的outlook是设置的,所以你必须在发送电子邮件之前选择其中一个选项,这可能是导致错误的原因。对于这个问题,我所知道的解决方案并不多,除了停用插件外,这个插件要求你在发送电子邮件之前给邮件贴上标签。但是也许其他人有其他的建议。