excel - 在 excel vba、OLE 问题上发送大量电子邮件
问题描述
我希望你做得很好。
我正在使用此代码在 VBA Excel 中发送电子邮件,但它只能工作一次,然后我必须在任务管理器上关闭 Outlook。如果我不这样做,我会收到一条消息“Microsoft Excel 正在等待另一个应用程序完成 OLE 操作”。我唯一需要做的就是关闭任务管理器上的 Outlook 应用程序,然后它就可以正常工作了。
你能帮我解决这个问题吗?下面我将发布我的代码
Dim email As Outlook.MailItem
Dim direc As String
Dim body As String
Set A = New Outlook.Application
For i = 2 To ActiveSheet.Cells(Rows.Count, 16).End(xlUp).Row
direc = Worksheets("NewSheet").Cells(i, 16).Value
Set email = A.CreateItem(emailItem)
With email
direc = Worksheets("NewSheet").Cells(i, 16).Value
If (direc <> "0") Then
.To = direc
.Subject = "Notification Test"
body = Worksheets("NewSheet").Cells(i, 14)
.HTMLBody = "<HTML><BODY style=font-size:11pt;font-family:Calibri>This is a notification reminder to let you know that you have <b>" & body & "</b> open contact(s) that you must Update</BODY><br><br>Best Regards, </br></br><br> Anonymous </br></HTML>"
.Display
.Send
End If
End With
Next i
非常感谢您的时间和帮助。
解决方案
不要同时调用Display和Send。摆脱显示线。
推荐阅读
- android - 詹金斯:离子安卓构建失败
- java - 在 springboot aws lambda 中注入服务
- angular - 页面刷新后保存并保留下拉值 PrimeNG
- xamarin.forms - 使用 xamarin 表单获取移动设备的宽度和高度
- javascript - 使用 angularfire2 从 Firebase 获取数据(文档示例)
- ssas - SSAS 计算成员上的复杂过滤器
- javascript - 如何在 jplayer 中调整搜索栏/进度条的大小?
- vba - 将字符串写入 txt 文件并将其替换为 Excel 列表
- jquery - 分配 src="@URL.action" 时如何显示特定错误
- vba - 粘贴无法正常工作,有时会粘贴重复数据