2011-03-28 244 views
3

嘿,伙计们。我试着做一个通讯电子邮件有链接到邮件不同的锚的idnex,但到目前为止,它似乎没有任何客户端的工作。这是代码:链接锚在HTML电子邮件

<ul style="list-style: none; margin: 0px; padding: 0px; "> 
    <li><a href="#anchor1">Sehen wir uns auf der ISH?</a></li> 
    <li><a href="#anchor1">Sehen wir uns auf der ISH?</a></li> 
    <li><a href="#anchor1">Sehen wir uns auf der ISH?</a></li> 
    <li><a href="#anchor1">Sehen wir uns auf der ISH?</a></li> 
    <li><a href="#anchor1">Sehen wir uns auf der ISH?</a></li> 
</ul> 

... 

<a name="anchor1" id="anchor1">foo</a> 

有何甚至怪异,在GMAIL我的ID标签消失,我的名字标签得到某种怪异的前缀,如“124335132_anchor1”。我能做什么?

回答

2

电子邮件客户端不是Web浏览器或设计为。他们留下了大量可能被认为是“非常基本”的东西。

使各个环节的绝对和他们在Web浏览器中打开的计划。

+0

我知道,但客户想在邮件的开头的索引内部链接到同一:( – 2011-03-28 11:05:27

+1

的部分我想辞掉工作,有一辆卡车装满了钱拉起来,每天送我的£10个音符的情况下。:)不幸的是,无论是我,也不是你的客户是会得到他们想要的东西。 – Quentin 2011-03-28 11:06:43

+1

但是,IT可以在电子邮件内制作锚链接,不是吗? – 2011-03-28 12:12:33

-1

不知道我得到你的意思..但是,它看起来像你想送MIMEBody作为电子邮件的内容,所以该电子邮件看起来像一个HTML格式..如果是的话,这里是一些从片我的Java代码:

@Override 
    public void coba() { 
     try { 

      MimeMessage message = new MimeMessage(mailSession); 
      message.setSubject("Whatever"); 
      message.setRecipient(RecipientType.TO, new InternetAddress("[email protected]", "SomeName Name")); 

      // 
      // This HTML mail have to 2 part, the BODY and the embedded image 
      // 
      MimeMultipart multipart = new MimeMultipart("related"); 

      // first part (the html) 
      BodyPart messageBodyPart = new MimeBodyPart(); 
      String htmlText = "<div style=\"width:800px; background-color:#525252\"><h1>Header</h1></div><br /><div style=\"width:200px; background-color:#ff0000; float: left\"><h3>Navigation Panel</h3><ul><li>link <a href=\"http://google.com\">here</a></li><li>link <a href=\"http://google.com\">here</a></li></ul></div><div style=\"width:600px; background-color:#727272; float: left\"><h3>Content</h3><p>blabla blabla blabla blabla blabla</p><br /><img src=\"cid:image\" /></div>"; 
      messageBodyPart.setContent(htmlText, "text/html"); 

      // add it 
      multipart.addBodyPart(messageBodyPart); 

      // second part (the image) 
      messageBodyPart = new MimeBodyPart(); 
      DataSource fds = new FileDataSource("C:/img/lion.JPG"); 
      messageBodyPart.setDataHandler(new DataHandler(fds)); 
      messageBodyPart.setHeader("Content-ID","<image>"); 

      // add it 
      multipart.addBodyPart(messageBodyPart); 

      // put everything together 
      message.setContent(multipart); 

      Transport.send(message); 

      //System.out.println("Successfully Send Email(" + subject + ") to " + emailAddress); 

     } catch(Exception e) { 
      e.printStackTrace(); 
     } 
    } 

我发送一封电子邮件,HTML格式,这里是截屏上的Gmail

here is the screen shot

希望它有什么用你的邮件内容..

2

你知道你平时有串

<div id="boom">... 

,并要锚从别的地方链接,你将进入

<a href="#boom"></a> 

所以现在你会除了使用名称标签你的目的地。

<a name="boom"></a><div id="boom">... 

Viola!锚链接在HTML电子邮件中。

0

要与展望2010年工作,它必须是这样的:

<a href="#section1">Jump to section!</a> 
<p>A bunch of content</p> 
<a name="section1">An anchor!</a>