This is close to a lot of different questions that have been asked and I have gone through them all, but I can't quite sort out the best approach.
This is what I have read (and tried) so far:
http://msdn.microsoft.com/en-us/library/ff519602%28v=office.11%29.aspx
http://social.msdn.microsoft.com/Forums/en-US/exceldev/thread/955fca20-c3a3-4523-b2d2-ac9016ae1ff8
I tried to convert the RangetoHTML function into vb.net, but I never really got it working, so if anyone has any tips for getting this solution to work I would love any guidance you have. I copied the code from the second link directly and changed it so I thought it would work, but I kept getting a COM exception in one of the pastespecial calls.
http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/9d9e1583-064a-4085-bc65-8f809d73dbb3
http://www.vboffice.net/sample.html?mnu=2&lang=en&smp=41&cmd=showitem&pub=6
Here they are proposing using Word as a stopping point (or as the editor in outlook, which is the default for my outlook version), which is reasonable, but I have been running into trouble with what exactly is going on here:
Sub CopyFromExcelIntoEMail()
Dim Doc As Word.Document
Dim wdRn As Word.Range
Dim Xl As Excel.Application
Dim Ws As Excel.Worksheet
Dim xlRn As Excel.Range
Set Doc = Application.ActiveInspector.WordEditor
Set wdRn = Doc.Range
Set Xl = GetObject(, "Excel.Application")
Set Ws = Xl.Workbooks("Mappe1.xls").Worksheets(1)
Set xlRn = Ws.Range("b2", "c6")
xlRn.Copy
wdRn.Paste
End Sub
To get this to work in vb.net I think I have to open up a word document not activeinspector.wordeditor (at least it is not working the way they have it there), but when I do that I am not getting any data (says nothing is pasted) from the wdRn.paste call, which seems right to me, since I never defined it as anything.
http://www.outlookcode.com/d/code/htmlimg.htm
I also came across that solution, which I am looking into right now, but I wanted to get this posted now to see if anyone had any thoughts and might be able to guide me to a better path.
I can post my code as requested, but it is really just variations of what is in those links and trying to get it to work in vb.net. I suppose an option would be to switch to VBA, but I like that VB.NET can be standalone and is easier to get to my coworkers.
Thank you Stack Overflow!
In the end I switched to using .htmlbody
in conjunction with converting all of the tables to image files, which allowed me to save them and input them with <img src>
, so html saved the day. The added benefit is that images will display fully without truncation on blackberries, which was another issue I had run into.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.