开发者

javamail mail image located on remote machine

I have a method that sends an HTML email and a picture embedded, to reference an image from my machine, eg c:/image.gif the method works well but I dont know how to add an image that is in a remote machine which I know your IP address and the path where the image. My code to add the image I have it like this:

BodyPart imagen = new MimeBodyPart(); 

DataSource ds=new FileDataSource("c:/image.gif"); 
image.setDataHandler(new DataHandler(ds)); 

image.setHeader("Content-ID","img");

if i have the path 开发者_高级运维\\10.33.5.123\project\2011\doctos\img\image.gif


Use an URLDataSource instead, like so:

BodyPart imagen = new MimeBodyPart(); 

URL url = new URL("http://server.com/mybestpicture.jpg");
URLDataSource ds = new URLDataSource(url); 
image.setDataHandler(new DataHandler(ds)); 

image.setHeader("Content-ID", "img");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜