在 excel 中创建超链接以通过 VBA 打开特定电子邮件 Outlook
Create Hyperlink in excel to open specific email Outlook by VBA
我正在 Outlook 中编写 VBA 代码,以将所有电子邮件信息跟踪到 1 个 Excel 文件。
对于每封电子邮件,我会将信息放在 Excel 的 1 行中。并且我想在Excel文件中添加一个超链接来打开相应的Email。
我的代码如下所示:
Set objFD = objNS.Folders("dtk142@aaaa.com")
Set objToFD = objFD.Folders("Inbox")
For Each Msg In objToFD.Items
'' mail information
mDate = Msg.ReceivedTime
mSubject = Msg.Subject
mSender = Msg.SenderName
mSAddress = Msg.SenderEmailAddress
' put to excel
xlTmp.Sheets("RequestTracker").Cells(cntrow, 1).Value = cntID
xlTmp.Sheets("RequestTracker").Cells(cntrow, 2).Value = mDate
xlTmp.Sheets("RequestTracker").Cells(cntrow, 3).Value = "Email"
xlTmp.Sheets("RequestTracker").Cells(cntrow, 5).Value = mSAddress
xlTmp.Sheets("RequestTracker").Cells(cntrow, 7).Value = user
xlTmp.Sheets("RequestTracker").Cells(cntrow, 11).Value = mSubject
'' code to add hyperlink to the email item here
cntrow = cntrow + 1
cntID = cntID + 1
Next
Next
现在我无法在 excel 中创建超链接来打开相应的电子邮件。在这种情况下请帮助我。谢谢!!!
一个简单的超链接不允许在 Outlook 中打开邮件。相反,您需要处理超链接点击(或按钮)并在 Outlook 中找到相应的条目。 Excel 工作簿中显示的属性不允许唯一标识邮件项目。您可以使用 EntryID 值,但在 Outlook 中将项目移动到另一个 store/folder 时,它可能会发生变化。以下是 MSDN 的说明:
A MAPI store provider assigns a unique ID string when an item is created in its store. Therefore, the EntryID property is not set for a Microsoft Outlook item until it is saved or sent. The EntryID changes when an item is moved into another store, for example, from your Inbox to a Microsoft Exchange Server public folder, or from one Personal Folders (.pst) file to another .pst file. Solutions should not depend on the EntryID property to be unique unless items will not be moved.
作为解决方法,您可以使用您自己生成的 ID(请参阅 UserProperties.Add)将用户 属性 添加到 Outlook 项目,并将其与其他人一起存储在 Excel 行中可读属性。
最后,您可能会发现 Getting Started with VBA in Outlook 2010 文章很有帮助。
我正在 Outlook 中编写 VBA 代码,以将所有电子邮件信息跟踪到 1 个 Excel 文件。 对于每封电子邮件,我会将信息放在 Excel 的 1 行中。并且我想在Excel文件中添加一个超链接来打开相应的Email。
我的代码如下所示:
Set objFD = objNS.Folders("dtk142@aaaa.com")
Set objToFD = objFD.Folders("Inbox")
For Each Msg In objToFD.Items
'' mail information
mDate = Msg.ReceivedTime
mSubject = Msg.Subject
mSender = Msg.SenderName
mSAddress = Msg.SenderEmailAddress
' put to excel
xlTmp.Sheets("RequestTracker").Cells(cntrow, 1).Value = cntID
xlTmp.Sheets("RequestTracker").Cells(cntrow, 2).Value = mDate
xlTmp.Sheets("RequestTracker").Cells(cntrow, 3).Value = "Email"
xlTmp.Sheets("RequestTracker").Cells(cntrow, 5).Value = mSAddress
xlTmp.Sheets("RequestTracker").Cells(cntrow, 7).Value = user
xlTmp.Sheets("RequestTracker").Cells(cntrow, 11).Value = mSubject
'' code to add hyperlink to the email item here
cntrow = cntrow + 1
cntID = cntID + 1
Next
Next
现在我无法在 excel 中创建超链接来打开相应的电子邮件。在这种情况下请帮助我。谢谢!!!
一个简单的超链接不允许在 Outlook 中打开邮件。相反,您需要处理超链接点击(或按钮)并在 Outlook 中找到相应的条目。 Excel 工作簿中显示的属性不允许唯一标识邮件项目。您可以使用 EntryID 值,但在 Outlook 中将项目移动到另一个 store/folder 时,它可能会发生变化。以下是 MSDN 的说明:
A MAPI store provider assigns a unique ID string when an item is created in its store. Therefore, the EntryID property is not set for a Microsoft Outlook item until it is saved or sent. The EntryID changes when an item is moved into another store, for example, from your Inbox to a Microsoft Exchange Server public folder, or from one Personal Folders (.pst) file to another .pst file. Solutions should not depend on the EntryID property to be unique unless items will not be moved.
作为解决方法,您可以使用您自己生成的 ID(请参阅 UserProperties.Add)将用户 属性 添加到 Outlook 项目,并将其与其他人一起存储在 Excel 行中可读属性。
最后,您可能会发现 Getting Started with VBA in Outlook 2010 文章很有帮助。