Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.NET editing MailAttachment Content-ID in MailMessage

Status
Not open for further replies.

napa1m

Programmer
Jul 24, 2000
39
TH
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top