简体   繁体   中英

Indexed Hyperlinks for Outlook Email Using VBA

I'm Trying to create a macro where I want an index list which could jump to specific header tags in the same email page.

I have tired using anchor elements and id's, but it is not working.

Here is my code.

Could you please let me know how I can solve the issue at hand?

With 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'\>"

As destination you have to user the tag .

you have to put

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

its better to put both name and id because the mail clients have distinct ways to process the anchors.

Also, you have to pay attention to the fact that some clients simply ignore or block the anchors.

good luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM