Hi, I'm using VB.NET and used the example from Microsoft's website to send a HTML Email. I have it sending attachments and such... however, I wish to embed a image that is attached into the message. I know that to do this, I must set the Content-ID (so I guess it is linked and not actually embedded as such). However... I have been unable to actually set this Content-ID nor reference it... I have included the code to create and send the email below:
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim sb As New StringBuilder()
sb.Append(Trim(txtMessage.Text))
sb.Append(vbCrLf)
Dim mailMsg As New MailMessage()
With mailMsg
.From = Trim("FROM_ADDRESS"
.To = Trim("TO_ADDRESS"
.Subject = txtSubject.Text.Trim
.Body = sb.ToString
.Priority = MailPriority.Normal
.BodyFormat = MailFormat.Html
If Not IsNothing(arlAttachments) Then
Dim mailAttachment As Object
For Each mailAttachment In arlAttachments
.Attachments.Add(mailAttachment)
Next
End If
End With
SmtpMail.SmtpServer = "MAIL_SERVER"
Try
SmtpMail.Send(mailMsg)
MessageBox.Show("Broadcast E-Mail Successfully Sent!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch exp As Exception
MessageBox.Show("Broadcast E-Mail Failed! Reason: " & exp.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Any help at all would be greatly appreciated. Thanks!
napa1m
hansen@ithsite.com
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim sb As New StringBuilder()
sb.Append(Trim(txtMessage.Text))
sb.Append(vbCrLf)
Dim mailMsg As New MailMessage()
With mailMsg
.From = Trim("FROM_ADDRESS"
.To = Trim("TO_ADDRESS"
.Subject = txtSubject.Text.Trim
.Body = sb.ToString
.Priority = MailPriority.Normal
.BodyFormat = MailFormat.Html
If Not IsNothing(arlAttachments) Then
Dim mailAttachment As Object
For Each mailAttachment In arlAttachments
.Attachments.Add(mailAttachment)
Next
End If
End With
SmtpMail.SmtpServer = "MAIL_SERVER"
Try
SmtpMail.Send(mailMsg)
MessageBox.Show("Broadcast E-Mail Successfully Sent!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch exp As Exception
MessageBox.Show("Broadcast E-Mail Failed! Reason: " & exp.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Any help at all would be greatly appreciated. Thanks!
napa1m
hansen@ithsite.com