使用 VBA 检索截断的 Outlook 电子邮件标头 [英] Truncated Outlook email headers retrieved using VBA
本文介绍了使用 VBA 检索截断的 Outlook 电子邮件标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想访问 Outlook 2010 中的电子邮件标头.我使用下面的代码,但不幸的是结果只包含标题的前 252 个字符.对我做错了什么有什么建议吗?
I want to access the email headers in Outlook 2010. I use the code below but unfortunately the result contains only the first 252 characters of the header. Any suggestion on what I'm doing wrong?
Dim strHeader As String
strHeader = GetInetHeaders(olItem)
MsgBox "Truncated string: " & strHeader
和
Function GetInetHeaders(olkMsg As Outlook.MailItem) As String
' Purpose: Returns the internet headers of a message.'
' Written: 4/28/2009'
' Author: BlueDevilFan'
' Outlook: 2007'
Const PR_TRANSPORT_MESSAGE_HEADERS = "http://schemas.microsoft.com/mapi/proptag/0x007D001E"
Dim olkPA As Outlook.PropertyAccessor
Set olkPA = olkMsg.PropertyAccessor
GetInetHeaders = olkPA.GetProperty(PR_TRANSPORT_MESSAGE_HEADERS)
Set olkPA = Nothing
End Function
推荐答案
Msgbox 不是证明截断的好方法.文本可以被合法地截断.
Msgbox is not a good method of proving truncation. Text can be legitimately truncated.
邮件项目中的文本似乎没有被截断.至少我没有注意到切断信息.
Text in a mailitem does not appear to be truncated. At least I do not notice cut off information.
Private Sub Test_GetInetHeaders()
Dim olNewmail As mailItem
Dim strHeader As String
Dim olItem As mailItem
Set olItem = ActiveInspector.currentItem
strHeader = GetInetHeaders(olItem)
Set olNewmail = CreateItem(olMailItem)
olNewmail.body = strHeader
olNewmail.Display
MsgBox "Truncated string if limit exceeded: " & strHeader
ExitRoutine:
Set olItem = Nothing
Set olNewmail = Nothing
End Sub
Function GetInetHeaders(olkMsg As outlook.mailItem) As String
' Purpose: Returns the internet headers of a message.'
' Written: 4/28/2009'
' Author: BlueDevilFan'
' Outlook: 2007'
Const PR_TRANSPORT_MESSAGE_HEADERS = "http://schemas.microsoft.com/mapi/proptag/0x007D001E"
Dim olkPA As outlook.propertyAccessor
Set olkPA = olkMsg.propertyAccessor
GetInetHeaders = olkPA.GetProperty(PR_TRANSPORT_MESSAGE_HEADERS)
Set olkPA = Nothing
End Function
这篇关于使用 VBA 检索截断的 Outlook 电子邮件标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文