Saving Message as text but keeping unicode

C

chris

I am saving Outlook items using the SaveAs method to a Text file using
OlSaveAsType.olTXT as the Parameter however I am losing the Unicode
within the Item itself to the SaveAs method (it replaces the unicode
with garbage or ???).

Is there a way to preserve the unicode but still save it as a txt file?
I have tried RTF but this is not what I need because it keeps hold of
the Embedded attachments in the mime section and all I want it textual
representation of the message.

The other option available to me would be to save it to HTML but I know
that not all items save to HTML and if I convert an item that is
originally RTF it will lose its formatting on conversion.

i.e.
If oMailItem.BodyFormat = OlBodyFormat.olFormatHTML Then
oMailItem.BodyFormat = OlBodyFormat.olFormatRichText
End If
or vice-versa

Any help would be appreciated.

Thanks,

Chris


Below is the Save function I am using:

Public Function SaveOlItem(ByVal oItem As Object, ByVal sFile As
String, ByVal SaveFileFormat As OlSaveAsType) As Long

Dim oMailItem As Outlook.MailItem
Dim oMeetingItem As Outlook.MeetingItem
Dim oApptItem As Outlook.AppointmentItem
Dim oContactItem As Outlook.ContactItem
Dim oDistListItem As Outlook.DistListItem
Dim oDocItem As Outlook.DocumentItem
Dim oNoteItem As Outlook.NoteItem
Dim oPostItem As Outlook.PostItem
Dim oReportItem As Outlook.ReportItem
Dim oTaskItem As Outlook.TaskItem
Dim oTaskReqItem As Outlook.TaskRequestItem
Dim oTaskReqAccItem As Outlook.TaskRequestAcceptItem
Dim oTaskReqDecItem As Outlook.TaskRequestDeclineItem
Dim oTaskReqUpItem As Outlook.TaskRequestUpdateItem
On Error GoTo Error_Handler

Select Case oItem.Class
Case olMail
Set oMailItem = oItem.Copy
oMailItem.SaveAs sFile, SaveFileFormat
oMailItem.Copy
Set oMailItem = Nothing
Case olMeeting
Set oMeetingItem = oItem.Copy
oMeetingItem.SaveAs sFile, SaveFileFormat
Set oMeetingItem = Nothing
Case olMeetingRequest
Set oMeetingItem = oItem.Copy
oMeetingItem.SaveAs sFile, SaveFileFormat
Set oMeetingItem = Nothing
Case olAppointment
Set oApptItem = oItem.Copy
oApptItem.SaveAs sFile, SaveFileFormat
Set oApptItem = Nothing
Case olContact
Set oContactItem = oItem.Copy
oContactItem.SaveAs sFile, SaveFileFormat
Set oContactItem = Nothing
Case olDistributionList
Set oDistListItem = oItem.Copy
oDistListItem.SaveAs sFile, SaveFileFormat
Set oDistListItem = Nothing
Case olDocument
Set oDocItem = oItem.Copy
oDocItem.SaveAs sFile, SaveFileFormat
Set oDocItem = Nothing
Case olNote
Set oNoteItem = oItem.Copy
oNoteItem.SaveAs sFile, SaveFileFormat
Set oNoteItem = Nothing
Case olPost
Set oPostItem = oItem.Copy
oPostItem.SaveAs sFile, SaveFileFormat
Set oPostItem = Nothing
Case olReport
Set oReportItem = oItem.Copy
oReportItem.SaveAs sFile, SaveFileFormat
Set oReportItem = Nothing
Case olTask
Set oTaskItem = oItem.Copy
oTaskItem.SaveAs sFile, SaveFileFormat
Set oTaskItem = Nothing
Case olTaskRequest
Set oTaskReqItem = oItem.Copy
oTaskReqItem.SaveAs sFile, SaveFileFormat
Set oTaskReqItem = Nothing
Case olTaskRequestAccept
Set oTaskReqAccItem = oItem.Copy
oTaskReqAccItem.SaveAs sFile, SaveFileFormat
Set oTaskReqAccItem = Nothing
Case olTaskRequestDecline
Set oTaskReqDecItem = oItem.Copy
oTaskReqDecItem.SaveAs sFile, SaveFileFormat
Set oTaskReqDecItem = Nothing
Case olTaskRequestUpdate
Set oTaskReqUpItem = oItem.Copy
oTaskReqUpItem.SaveAs sFile, SaveFileFormat
Set oTaskReqUpItem = Nothing
Case Else
oItem.SaveAs sFile, SaveFileFormat
End Select

SaveOlItem = 0
Exit Function

Error_Handler:

SaveOlItem = Err.Number

'House Cleaning
Set oMailItem = Nothing
Set oPostItem = Nothing
Set oMeetingItem = Nothing
Set oApptItem = Nothing
Set oContactItem = Nothing
Set oDistListItem = Nothing
Set oDocItem = Nothing
Set oNoteItem = Nothing
Set oReportItem = Nothing
Set oTaskItem = Nothing
Set oTaskReqItem = Nothing
Set oTaskReqAccItem = Nothing
Set oTaskReqDecItem = Nothing
Set oTaskReqUpItem = Nothing

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top