使用VBA的Outlook电子邮件的索引超链接

时间:2018-09-08 19:40:56

标签: excel vba excel-vba hyperlink outlook

我正在尝试创建一个我想要一个索引列表的宏,该列表可以跳转到同一电子邮件页面中的特定标头标签。

我已经厌倦了使用锚元素和id的操作,但是它不起作用。

这是我的代码。

您能告诉我如何解决当前问题吗?

使用MailItem:

    .BodyFormat = olFormatHTML
    .Display
    .HTMLBody = "<a href='#section1'>CS Brazil Lineup vs Balance Sheet Demand -Sept'18</a>" _
    & "<br>" & "<h3 name = 'section_1'><span style='background-color: #FFFF00'><font color='blue'>Regional LU</font></span></h3>" _
    & "<br>" & "<img src='C:\Users\ramesn1\Documents\New folder\Regional Line up Sugar.png'\>" _
    & "<br>" & "<h3 id = 'Section2'><span style='background-color: #FFFF00'><font color='blue'>Unknowns for the moment for Sept : 169kmt</font></span></h3>" _
    & "<br>" & "<img src=''\>" _
    & "<br>" & "<h3 name = 'Section3'><span style='background-color: #FFFF00'><font color='blue'>CS Brazil Lineup vs Balance Sheet Demand " & MonthYear & "</font></span></h3>" _
    & "<br>" & "<img src='C:\Users\ramesn1\Documents\New folder\workSugar.png'\>" _
    & "<br>" & "<h3 id = 'Section4'><span style='background-color: #FFFF00'><font color='blue'>Next 7 Months Destination Demand</font></span></h3>" _
    & "<br>" & "<img src='C:\Users\ramesn1\Documents\New folder\workForecast.png'\>" _
    & "<br>" & "<h3><span style='background-color: #FFFF00'><font color='blue'>% Representation of Total Exports for 1st Day " & MonthYear & "</font></span></h3>" _
    & "<br>" & "<img src='C:\Users\ramesn1\Documents\New folder\1st date demandTable1.png'\>" _
    & "<br>" & "<img src='C:\Users\ramesn1\Documents\New folder\1st date demandTable2.png'\>" _
    & "<br>" & "<h3><span style='background-color: #FFFF00'><font color='blue'>Terminal Capacity/Waiting Time </font></span></h3>" _
    & "<br>" & "<img src='C:\Users\ramesn1\Documents\New folder\QUEUE.png'\>" _
    & "<br>" & "<h3><span style='background-color: #FFFF00'><font color='blue'>CS LU Nominations to be Shipped  Sugar + Other commodities (YoY)</font></span></h3>" _
    & "<br>" & "<img src='C:\Users\ramesn1\Documents\New folder\CS(YOY)Chart 1.png'\>" _
    & "<br>" & "<img src='C:\Users\ramesn1\Documents\New folder\CS(YOY)Chart 3.png'\>" _
    & "<br>" & "<h3><span style='background-color: #FFFF00'><font color='blue'>Terminal Performance & Nominations for G&O +Sugar -" & PreviousMonth & " & " & MonthYear & " </font></span></h3>" _
    & "<br>" & "<img src='C:\Users\ramesn1\Documents\New folder\Lineup ProgressAll Commodities.png'\>" _
    & "<br><br>" _
    & "<br>" & "<img src='C:\Users\ramesn1\Documents\New folder\Lineup ProgressGrains.png'\>" _
    & "<br><br>" _
    & "<br>" & "<img src='C:\Users\ramesn1\Documents\New folder\Lineup ProgressSugar.png'\>"

1 个答案:

答案 0 :(得分:0)

作为目的地,您必须使用标签。

你必须放

<a name="section1" id="section1">

最好同时输入名称和ID,因为邮件客户端有不同的方式来处理锚点。

此外,您还必须注意某些客户端只是忽略或阻止锚点这一事实。

祝你好运