Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET Objects

 AfterLogic Forum : MailBee.NET Objects
Subject Topic: Create EML from Outlook Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
jvinis
Newbie
Newbie


Joined: 20 May 2008
Online Status: Offline
Posts: 18
Posted: 19 January 2009 at 6:28am | IP Logged Quote jvinis

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 View jvinis's Profile Search for other posts by jvinis
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 19 January 2009 at 7:21am | IP Logged Quote Igor

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 View Igor's Profile Search for other posts by Igor
 
jvinis
Newbie
Newbie


Joined: 20 May 2008
Online Status: Offline
Posts: 18
Posted: 19 January 2009 at 8:01am | IP Logged Quote jvinis

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 View jvinis's Profile Search for other posts by jvinis
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 19 January 2009 at 8:31am | IP Logged Quote Igor

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 View Igor's Profile Search for other posts by Igor
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide