startuga Posted September 1, 2014 Report Share Posted September 1, 2014 Boa tarde, Tenho estado a tentar colar imagens e enviar por emial através do VB, mas nao estou a conseguir, quando envio não recebo a imagem mas sim um conjunto enorme de varios caracteres. Posto isto gostaria de saber se é realmente possivel colar e enviar imagens via email atraves do VB. Obrigado : ) Link to comment Share on other sites More sharing options...
RicardoCosta Posted September 1, 2014 Report Share Posted September 1, 2014 Podes postar o código de como inseres a imagem no email? Link to comment Share on other sites More sharing options...
startuga Posted September 1, 2014 Author Report Share Posted September 1, 2014 (edited) De momento é isto que tenho Imports Microsoft.Office Public Class Form1 Dim sFilesource As String Dim sName As String Private Sub setEmailSend(sSubject As String, sBody As String, _ sTo As String, sCC As String, _ sFilename As String, sDisplayname As String) Dim oApp As Interop.Outlook._Application oApp = New Interop.Outlook.Application Dim oMsg As Interop.Outlook._MailItem oMsg = oApp.CreateItem(Interop.Outlook.OlItemType.olMailItem) oMsg.Subject = sSubject oMsg.Body = sBody oMsg.To = sTo oMsg.CC = sCC Dim strS As String = sFilename Dim strN As String = sDisplayname If sFilename <> "" Then Dim sBodyLen As Integer = Int(sBody.Length) Dim oAttachs As Interop.Outlook.Attachments = oMsg.Attachments Dim oAttach As Interop.Outlook.Attachment oAttach = oAttachs.Add(strS, , sBodyLen, strN) End If oMsg.Send() MessageBox.Show("Email Send", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation) txtBody.Rtf = "" txtTo.Text = "" txtCC.Text = "" txtFile.Text = "" txtSubject.Text = "" KillOutLookProcess() End Sub Private Sub KillOutLookProcess() Try Dim Xcel() As Process = Process.GetProcessesByName("OUTLOOK") For Each Process As Process In Xcel Process.Kill() Next Catch ex As Exception End Try End Sub Public Function AppPath() Return System.AppDomain.CurrentDomain.BaseDirectory End Function Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click If txtTo.Text <> "" Then setEmailSend(txtSubject.Text, txtBody.Rtf, txtTo.Text, txtCC.Text, sFilesource, sName) Else MessageBox.Show("No Recipient", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information) End If End Sub End Class Edited September 1, 2014 by startuga Link to comment Share on other sites More sharing options...
RicardoCosta Posted September 1, 2014 Report Share Posted September 1, 2014 Diz-me uma coisa tu queres adicionar a imagem como anexo ou queres mesmo colar no body e ao abrir mostra logo? No caso de ser como anexo pelo teu código não vejo nada de anormal. Se for para por no body tens de configurar o email do tipo html e tens de editar de forma a que tenha o seguinte código: <img src="cid:nomedaimagem.jpg" alt="img1"> A imagem terá de estar em anexo e o cid terá de ter exactamente o mesmo nome como está no anexo. Link to comment Share on other sites More sharing options...
startuga Posted September 1, 2014 Author Report Share Posted September 1, 2014 Pretendo mesmo colar a imagem no body, e ao abrir mostrar logo. Link to comment Share on other sites More sharing options...
RicardoCosta Posted September 1, 2014 Report Share Posted September 1, 2014 Então tens de fazer como te indiquei 😉 Link to comment Share on other sites More sharing options...
startuga Posted September 2, 2014 Author Report Share Posted September 2, 2014 Ok, através dessa forma já consegui fazer. Agora a minha questão e tornando isto mais friendly user, não existe forma de fazer copy/paste da imagem diretamente na textbox/richtextbox? Link to comment Share on other sites More sharing options...
RicardoCosta Posted September 2, 2014 Report Share Posted September 2, 2014 Nesse aspecto já não te consigo ajudar porque eu próprio nunca o fiz mas pode ser que outro membro o saiba. Se calhar o mais indicado seria mesmo abrires outro tópico para essa questão em especifico. Link to comment Share on other sites More sharing options...
startuga Posted September 2, 2014 Author Report Share Posted September 2, 2014 Contornando isto, Ao anexar a imagem consigo fazer com que a mesma seja visualizada na richtextbox? 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