c# - How to place a self created bitmap in the html body of a mail -
to specify question: i'm creating bitmap object, want send email. don't want save before or upload webserver. attach , link attachement in html body of mail. i've searched quite time , can find answers in picture stored in file system or on server.
so there way whithout saving image before?
thanks
edit: i've tried around bit , came solution:
mailmessage mail = new mailmessage(); mail.to.add(new mailaddress("xxx@yyy.de")); mail.from = new mailaddress("xxx@yyy.de"); smtpclient sender = new smtpclient { host = "smtp.client", port = 25 }; mail.subject = "test"; body= "blablabla<br><img alt=\"\" hspace=0 src=\"cid:imagedid\" align=baseline border=0 ><br>blablabla"; alternateview htmlview = alternateview.createalternateviewfromstring(body, null, "text/html"); using (system.io.memorystream image = new system.io.memorystream()) { bitmap diagram = new bitmap("c:\\qwer.bmp"); diagram.save(image, system.drawing.imaging.imageformat.jpeg); linkedresource resource = new linkedresource(image, "image/jpeg"); resource.contentid = "imageid"; resource.transferencoding = system.net.mime.transferencoding.base64; htmlview.linkedresources.add(resource); mail.alternateviews.add(htmlview); sender.send(mail); }
but mailclient (lotus notes) doesnt open mail error: "no mime data". idea how solve this?
try creating in word (either image or whole email) drag on , copy , paste outlook. think auto attaches images embeds them.
Comments
Post a Comment