c# - Include image from website in mailitem.HTMLBody -


i developing add-in microsoft outlook adds image right before tag of html body. image located on remote server source of image tag http://someserver.com/image.jpg

this works expected on fresh e-mail ( aka new e-mail ) when user clicks reply, or forward reason image source gets changed cid:image001.jpg , actual image source gets put in alt tag.

i altering body on send event want image added after e-mail finished being written.

the code run @ send event

void outlookapplication_itemsend(object item, ref bool cancel)     {          if (item outlook.mailitem)         {             outlook.mailitem mailitem = (outlook.mailitem)item;              string image = "<img src='http://someserver.com/attach.jpg' width=\"100\" height=\"225\" alt=\"\" />";             string body = mailitem.htmlbody;              body = body.replace("</body>", image + "</body>");              mailitem.bodyformat = outlook.olbodyformat.olformathtml;             mailitem.htmlbody = body;         }     } 

so found way works. ended having create new mailitem, copy existing mailitem it, modify , send item , cancel original. following code shows how did it:

void outlookapplication_itemsend(object item, ref bool cancel)     {          if (item outlook.mailitem)         {             outlook.inspector currinspector;             currinspector = outlookapplication.activeinspector();             outlook.mailitem oldmailitem = (outlook.mailitem)item;             outlook.mailitem mailitem = oldmailitem.copy();             string image = "<img src='http://someserver.com/attach.jpg' width=\"1\" height=\"1\" alt=\"\" />";             string body = mailitem.htmlbody;              body = body.replace("</body>", image+"</body>");              mailitem.bodyformat = outlook.olbodyformat.olformathtml;             mailitem.htmlbody = body;              mailitem.send();             cancel = true;             currinspector.close(outlook.olinspectorclose.oldiscard);         }     } 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -