Outlook 2010 电子邮件正文为空 [英] Outlook 2010 Email body is empty

查看:61
本文介绍了Outlook 2010 电子邮件正文为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在基本的 .Body 工作中遇到了最严重的问题.我读过这个:VBA Outlook 2010 收到邮件.正文为空 但它是旧的,当我点击它时找不到答案中引用的另一个问题.这是我的基本代码.

I've having the worst problem with the basic .Body working. I've read this: VBA Outlook 2010 received mail .Body is empty but it is old and the other question referenced in the answer(s) is not found when I click on it. Here's my basic code.

Sub AutoReplyTrap(objInMail As MailItem)

Dim objOutMail As Outlook.MailItem

Dim vText As Variant
Dim sText As String
Dim strID As String
Dim sSubject As String
Dim vItem As Variant
Dim vFirstName As Variant
Dim i As Long
Dim j As Integer
Dim strSignature As String
Dim strSigString As String
Dim strFirstName As String
Dim strFirstLetter As String
Dim strEMailAddress As String
Dim blnFirstName As Boolean
Dim blnEMail As Boolean

' change the bodyformat to plain text
objInMail.BodyFormat = Outlook.OlBodyFormat.olFormatPlain

objInMail.Display

blnFirstName = False
blnEMail = False
j = 0

' believe there is a timing issue that Body may not be fully loaded.
' so I'm going to pause and loop through 20 times to see if it gets loaded.
WaitForBody:
sText = objInMail.Body
If sText = "" Then
    If j < 20 Then
        j = j + 1
        Sleep 1000
        GoTo WaitForBody
    End If
End If

If sText = "" Then
    MsgBox ("No body in email!")
    Exit Sub
End If

End Sub

如您所见,我认为可能是时间问题,因此我构建了循环以测试是否有实体,如果没有,请稍等,然后重试最多 20 次.

As you can see, I thought maybe it was a timing issue, so I built the loop to test if I have the body, and if not, wait a second and try again up to 20 times.

这是有趣的部分...如果我有 objInMail.Display 它可以工作,但是如果我删除那行,它将循环 20 次尝试并失败.虽然我不喜欢,但如果我可以取消显示"它,我可能会忍受显示,但我想知道 .close 是否真的会关闭电子邮件中的所有内容,我会再次丢失正文.

Here's the interesting part... IF I have the objInMail.Display it works, but if I remove that line it will loop through the 20 attempts and fail. Although I wouldn't like to, I might could live with the display if I could then "un-display" it, but I wonder if the .close actually will close everything with the email and I'll lose the body again.

显然,我更喜欢它在没有 objInMail.Display 的情况下工作.

Obviously, I'd prefer it just to work without the objInMail.Display.

有什么建议或建议吗?

推荐答案

如果不需要显示则:

objInMail.GetInspector

MailItem.GetInspector 属性 "... 返回一个 Inspector 对象,在其中显示项目..."

MailItem.GetInspector Property "... for returning an Inspector object in which to display the item ..."

我看到一份报告称行为已改变.GetInspector 可能不再可靠地替代 .Display.

I have seen a report that the behaviour has changed. GetInspector may no longer reliably replace .Display.

这篇关于Outlook 2010 电子邮件正文为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆