vba - Visual Basic - Screen shot then insert into email -


i new using visual basic. using visual basic in ms excel. struggling work out have paste screen shot email. have following, please tell need enter.

thanks

    sub addtonaughtylist()  '     ' addtonaughtylist macro     '     range("y3:z3").select     application.cutcopymode = false     selection.insert shift:=xldown, copyorigin:=xlformatfromleftorabove     range("u2:v2").select     selection.copy     range("y3:z3").select     selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _         :=false, transpose:=false     range("e2").select      dim aoutlook object     dim aemail object     dim studentname string     dim sendaddress string   ' copy picture      range("c6:s39").select     selection.copypicture appearance:=xlscreen, format:=xlbitmap  'setup email      set aoutlook = createobject("outlook.application")     set aemail = aoutlook.createitem(0)     studentname = activecell.value     sendaddress = range("d5")   'cells(1, "a").value  'set address      aemail.to = sendaddress  'set subject      aemail.subject = "weekly progress report " & studentname  'set body mail      aemail.htmlbody = "<font face=calibri><html><body>nat's *student needs attend friday detention* text goes here.</font><br /><br />" _  'paste email???????????  aemail.display 

i see 2 possible solutions:

  1. outlook uses word rendering/editing message bodies. so, can use word object model pasting images clipboard. wordeditor property of inspector class returns instance of document class word object model represents message body. paste or pastespecial methods of selection class insert contents of clipboard. see chapter 17: working item bodies more information.
  2. save screenshot file on disk , attach mail item attachment. add method of attachments class creates new attachment in attachments collection. can mention in message body. note, need assign cid attribute attached image add reference in body.

for example:

  attachment attachment = newmail.attachments.add(@"e:\pictures\image001.jpg", olattachmenttype.olembeddeditem, null, "some image display name");    string imagecid = "image001.jpg@123";    attachment.propertyaccessor.setproperty("http://schemas.microsoft.com/mapi/proptag/0x3712001e", imagecid);   newmail.htmlbody = string.format("<body><img src=\"cid:{0}\"></body>", imagecid); 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -