How can I forward an email and preserve its attachments?
The most common reason people have trouble with this is because they are not preserving the headers of the original message when setting the SMTP properties.
You will have to forward both the messagebody and the applicable message headers (specifically, the MIME headers). You don't want to just copy over all of the headers, because those headers were built for the original sender. What you can do is strip the MIME headers out of that message. The ones you want to look for are MIME-Version and content-type. The code below shows how you can do this...however rather than hard coding the mimeversion and content-type, you'll need to strip those from the original message headers (if they exist in there) much like I have stripped out the subject header. Hope this helps.
Private Sub Command1_Click()
POP1.MailServer = "server"
POP1.User = "me"
POP1.Password = "mypass"
POP1.Connect
POP1.MessageNumber = 2
POP1.Retrieve
SMTP1.MailServer = "server
SMTP1.From = "me@server"
SMTP1.SendTo = "you@server"
Dim startsubj As Integer
Dim subjlen As Integer
startsubj = InStr(1, POP1.MessageHeaders, "Subject:")
subjlen = InStr(startsubj, POP1.MessageHeaders, vbCrLf)
SMTP1.Subject = "FW: " + Mid(POP1.MessageHeaders, startsubj, subjlen)
SMTP1.MessageText = POP1.MessageText
SMTP1.OtherHeaders = "MIME-Version: 1.0" + vbCrLf + _
"Content-Type: multipart/mixed; " + _
"boundary = ""----=_NextPart_000_0004_01C11B4B.B5239630""" + vbCrLf
SMTP1.Send
End Sub
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.