startuga Posted September 2, 2014 Report Share Posted September 2, 2014 Bom dia, No seguimento deste tópico http://www.portugal-a-programar.pt/topic/67867-paste-image-and-send-via-email/ Pretendia saber se é possivel, colar imagens diretamente dentro uma richtextbox/texbox juntamente com texto etc... por forma a criar algo mais friendly user. Obrigado. Link to comment Share on other sites More sharing options...
startuga Posted September 2, 2014 Author Report Share Posted September 2, 2014 Já consegui por algo a trabalhar através deste código, Contudo sucede que ele guarda a imagem numa pasta temporaria e ao converter envia tudo em HTML, post isto quando envio o emial a imagem nao segue no texto :c Alguma idea de como solucionar a situacao? Public Function sRTF_To_HTML(ByVal sRTF As String) As String 'Declare a Word Application Object and a Word WdSaveOptions object Dim MyWord As Microsoft.Office.Interop.Word.Application Dim oDoNotSaveChanges As Object = _ Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges 'Declare two strings to handle the data Dim sReturnString As String = "" Dim sConvertedString As String = "" Try 'Instantiate the Word application, ‘set visible to false and create a document MyWord = CreateObject("Word.application") MyWord.Visible = False MyWord.Documents.Add() 'Create a DataObject to hold the Rich Text 'and copy it to the clipboard Dim doRTF As New System.Windows.Forms.DataObject doRTF.SetData("Rich Text Format", sRTF) Clipboard.SetDataObject(doRTF) 'Paste the contents of the clipboard to the empty, 'hidden Word Document MyWord.Windows(1).Selection.Paste() '…then, select the entire contents of the document 'and copy back to the clipboard MyWord.Windows(1).Selection.WholeStory() MyWord.Windows(1).Selection.Copy() 'Now retrieve the HTML property of the DataObject 'stored on the clipboard sConvertedString = _ Clipboard.GetData(System.Windows.Forms.DataFormats.Html) 'Remove some leading text that shows up in some instances '(like when you insert it into an email in Outlook sConvertedString = _ sConvertedString.Substring(sConvertedString.IndexOf("<html")) 'Also remove multiple  characters that somehow end up in there sConvertedString = sConvertedString.Replace("Â", "") '…and you're done. sReturnString = sConvertedString If Not MyWord Is Nothing Then MyWord.Quit(oDoNotSaveChanges) MyWord = Nothing End If Catch ex As Exception If Not MyWord Is Nothing Then MyWord.Quit(oDoNotSaveChanges) MyWord = Nothing End If MsgBox("Error converting Rich Text to HTML") End Try Return sReturnString End Function ' 'That does it. If you need to insert your HTML into an 'Outlook mail message (as I did) here's how to do it using the function above. ' Dim myotl As Microsoft.Office.Interop.Outlook.Application Dim myMItem As Microsoft.Office.Interop.Outlook.MailItem myotl = CreateObject("Outlook.application") myMItem = myotl.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem) myMItem.Subject = "This email was converted from rich text to HTML using a simple function in VB.net" myMItem.Display(False) myMItem.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML myMItem.HTMLBody = sConvertedString fonte: http://www.codeproject.com/Articles/51879/Converting-RTF-to-HTML-in-VB-NET-the-Easy-Way Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now