Hola a todos,
Estoy realizando una aplicación que envia plantillas por correo atraves de outlook.
Esto funciona, sin embargo desde hace un tiempo intento que funcione con imagenes. Las imagenes vienen en las propias plantillas en html.
Cuando las envio con el siguiente codigo, el cliente de correo no ve las imagenes.
Dichas he intentado con html filtrado, he copiado el codigo incrustando la imagen como embed dentro del html pero continuo con el mismo problema, sólo me ha funcionado apuntando las imagenes hacia internet con un servidor de imagenes tipo photobuquet, el problema es que el proxy no deja acceso a photobucket.
Código:
'References for templates.
Dim myStreamReaderL1 As System.IO.StreamReader
Dim myStr As String
Dim path As String
Dim item As Outlook.MailItem
Dim SigString As String
Dim Signature As String
Dim Body As String = Nothing
Dim subject As String
'READ TEMPLATES TO BE SEND
Private Sub readertemplate()
Try
myStreamReaderL1 = System.IO.File.OpenText(path)
myStr = myStreamReaderL1.ReadToEnd()
myStreamReaderL1.Close()
Dim comment As String = CommentTMPTxt.Text + vbNewLine & vbNewLine
myStr = myStr.Replace("[NAME]", UserTMPTxt.Text)
myStr = myStr.Replace("[NUMINC1]", IncTMPTxt.Text)
myStr = myStr.Replace("[NUMINC2]", IncTMPTxt.Text)
If Not CommentTMPTxt.Text = "" Then
myStr = myStr.Replace("[COMMENT]", comment)
ElseIf CommentTMPTxt.Text = "" Then
myStr = myStr.Replace("[COMMENT]", "")
End If
myStr = myStr.Replace("[ISSUE]", IssueTMPTxt.Text)
If EmailTMPTxt.Text = "" Or IncTMPTxt.Text = "" Then
MsgBox("Email addresss and Incident number is empty", MsgBoxStyle.Exclamation)
ElseIf Not EmailTMPTxt.Text = "" Or IncTMPTxt.Text = "" Then
item = olApp.CreateItem(Outlook.OlItemType.olMailItem)
item.To = EmailTMPTxt.Text
item.BodyFormat = OlBodyFormat.olFormatHTML
item.HTMLBody = myStr
'USING HAS A TEST
'item.SentOnBehalfOfName = "[email protected]"
item.SentOnBehalfOfName = CC1Emailadd
If LanguageCB.Text = "Spanish" Then
item.Subject = "CC1 - Numero de Incidencia " + IncTMPTxt.Text
ElseIf LanguageCB.Text = "French" Then
item.Subject = "CC1 - numéro de l'incident " + IncTMPTxt.Text
ElseIf LanguageCB.Text = "English" Then
item.Subject = "CC1 - Incident number " + IncTMPTxt.Text
ElseIf LanguageCB.Text = "German" Then
item.Subject = "CC1 - Incident-Nummer " + IncTMPTxt.Text
End If
item.Send()
MsgBox("Mail has been sent")
End If
Catch
MsgBox("Template can't be found. Please contact a L2 Analyst", MsgBoxStyle.Critical, vbOKOnly)
Threading.Thread.Sleep(60000)
End Try
End Sub
'SEND TEMPLATES.
Private Sub SendTMPBT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendTMPBT.Click
Dim olAccounts As Outlook.Accounts
olApp = New Outlook.Application()
olSession = olApp.Session
olAccounts = olSession.Accounts
If LanguageCB.Text = "Language" Then
MsgBox("Please choose the language and press sent", MsgBoxStyle.Information, vbOKOnly)
ElseIf Not LanguageCB.Text = "Language" Then
'CC1 SPANISH
If tempCB.Text = "CC1 email" And LanguageCB.Text = "Spanish" Then
'Holidays conditional.
If WeendoffCK.Checked Then
'if it is holiday or weekend.
path = "\\sfs.corp\Projects\ICT\SERVICEDESK_SHARE\SD_Only\Tools\JLTool\Template\CC1\CC1SPANISHholidays.html"
ElseIf Not WeendoffCK.Checked Then
'if it is not holiday or weekend.
path = "\\sfs.corp\Projects\ICT\SERVICEDESK_SHARE\SD_Only\Tools\JLTool\Template\CC1\CC1SPANISH.html"
End If
readertemplate()
ElseIf tempCB.Text = "CC1 email" And LanguageCB.Text = "English" Then
'Holidays conditional.
If WeendoffCK.Checked Then
'if it is holiday or weekend.
path = "\\sfs.corp\Projects\ICT\SERVICEDESK_SHARE\SD_Only\Tools\JLTool\Template\CC1\CC1ENGLISHholidays.html"
ElseIf Not WeendoffCK.Checked Then
'if it is not holiday or weekend.
path = "C:\Users\joserodriguezan\Desktop\CC1\CC1ENGLISH.html"
End If
readertemplate()
End If
Muchas gracias,