Author |
|
jvinis Newbie
Joined: 20 May 2008
Online Status: Offline Posts: 18
|
Posted: 19 January 2009 at 6:28am | IP Logged
|
|
|
Hello,
I am trying to create a outlook mail to eml but i dont know what to do with inline images. It reads them as file attachments but i want to have them as part to the body message.
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 19 January 2009 at 7:21am | IP Logged
|
|
|
If we understand you correctly, you are trying to use messages obtained from Microsoft Outlook as .msg files so that their attachments become .eml files attachments. Unfortunately, this cannot be achieved using MailBee.NET Objects as MSG files are not supported.
If that was not exactly what you are trying to do, please describe your task in more detail.
Regards,
Igor
|
Back to Top |
|
|
jvinis Newbie
Joined: 20 May 2008
Online Status: Offline Posts: 18
|
Posted: 19 January 2009 at 8:01am | IP Logged
|
|
|
let me be more specific im working on vb .net
I read from outlook from inbox my mails. i try to construct eml file.
If a mail has an inline image in body i get it as an attachment. I dont want this happen.
Try
For Each item As Outlook.MailItem In Inbox
mail.Id = item.EntryID
mail.UID = item.EntryID
mail.DateReceived = item.ReceivedTime
mail.From = item.SenderEmailAddress
If item.To IsNot Nothing Then
Names = item.To.Split(";")
For i As Integer = 0 To Names.GetUpperBound(0)
mail.To &= item.Recipients(i + 1).Address & ";"
Next
mail.To = mail.To.Remove(mail.To.LastIndexOf(";"), 1)
Else
mail.To = item.To
End If
If item.CC IsNot Nothing Then
Names = item.CC.Split(";")
index = Names.Length
For i As Integer = 0 To Names.GetUpperBound(0)
mail.CC &= item.Recipients(i + index + 1).Address & ";"
Next
mail.CC = mail.CC.Remove(mail.CC.LastIndexOf(";"), 1)
Else
mail.CC = item.CC
End If
If item.BCC IsNot Nothing Then
Names = item.BCC.Split(";")
index = Names.Length + index
For i As Integer = 0 To Names.GetUpperBound(0)
mail.BCC &= item.Recipients(i + index + 1).Address & ";"
Next
mail.BCC = mail.BCC.Remove(mail.CC.LastIndexOf(";"), 1)
Else
mail.BCC = item.BCC
End If
mail.Subject = item.Subject
mail.Body = item.HTMLBody
'Get Attachments
For Each attach As Outlook.Attachment In item.Attachments
TemporaryPath = My.Computer.FileSystem.GetTempFileName()
If attach.Type <> Outlook.OlAttachmentType.olEmbeddeditem Then
If InStr() Then
attach.SaveAsFile(TemporaryPath & attach.FileName)
ms = New MemoryStream()
msg = New MailBee.Mime.MailMessage()
msg.From.AsString = mail.From
msg.Subject = mail.Subject
msg.To.Add(mail.To)
If mail.CC IsNot Nothing Then
msg.Cc.Add(mail.CC)
End If
If mail.BCC IsNot Nothing Then
msg.Bcc.Add(mail.BCC)
End If
msg.Attachments.Add(TemporaryPath & attach.FileName, attach.FileName)
My.Computer.FileSystem.DeleteFile(TemporaryPath, FileIO.RecycleOption.DeletePermanently, FileIO.RecycleOption.DeletePermanently)
msg.BodyHtmlText = mail.Body
msg.SaveMessage(ms)
mail.Eml = Convert.ToBase64String(ms.ToArray())
msg = Nothing
If ms IsNot Nothing Then
ms.Close()
ms.Dispose()
ms = Nothing
End If
End If
Next
FoundOneMail = True
' Exit For
'End If
Next
Catch ex As Exception
resp.Status = 0
resp.ErrorText &= "CitronGo.Components.Mail.Outlook- Error in GetNewMessages" & vbCrLf & ex.ToString()
End Try
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 19 January 2009 at 8:31am | IP Logged
|
|
|
With regard to MIME message structure, the only difference between inline image and any other attachment is that the first one has ContentID property, it is used to reference this attachment from the message body.
In order to specify ContentID for inline image or any other embedded object, you'll need to use another overload of AttachmentCollection.Add method.
You should parse the message information to find out CIDs of those inline images, refer to Outlook API documentation for details.
Regards,
Igor
|
Back to Top |
|
|