Answered by:
body text email

Question
-
If I import the body text of an outlook email into a memo field , it seems the line-feeds are gone . is there a way to avoid that ?Tuesday, September 6, 2016 10:01 AM
Answers
-
Hi tekoko,
>>neither a long text or rich text field works
What is your Access version? How did you create the table and how did you set long text field? I made a test with below code and steps, it works under Access 2013.
1. Create a new table with Long Text field whose Text Format is Plain Text.
2. Run below code
Sub getOutlook() Dim ns As NameSpace Dim Inbox As MAPIFolder Dim SubFolder As MAPIFolder Dim Item As Object Dim Atmt As Attachment Dim FileName As String Dim MyDocPath As String Dim i As Integer Dim wsh As Object Dim fs As Object Dim TempRst As dao.Recordset Dim rst As dao.Recordset Dim aantalmails As Integer Set db = CurrentDb Set TempRst = CurrentDb.OpenRecordset("ImportOutlook") Set ns = GetNamespace("MAPI") Set Inbox = ns.GetDefaultFolder(olFolderInbox) Set SubFolder = Inbox.Folders("Celeste Li") i = Nz(DMax("ID", "Off"), 0) ' Check subfolder for messages and exit of none found If SubFolder.Items.Count = 0 Then Set SubFolder = Nothing Set Inbox = Nothing Set ns = Nothing Exit Sub End If For Each Item In SubFolder.Items i = i + 1 With TempRst Debug.Print Item.Body If Left(Item.Class, 2) = 43 Then .AddNew !Subject = Item.Subject !Body = Item.Body .Update Else .AddNew !Subject = Item.Subject !Body = Item.Body .Update End If End With Next Item End Sub
3. Check the output in Immdeiate window and check the value in the new table.
Best Regards,
Edward
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- Marked as answer by tekoko10 Thursday, September 8, 2016 7:12 AM
Thursday, September 8, 2016 2:25 AM
All replies
-
How exactly are you performing the import? If by code can you show us the code you are using.
Have you tried saving the source (with HTML tags)?
-- Daniel Pineault, 2010-2015 Microsoft MVP Professional Support: http://www.cardaconsultants.com MS Access Tips and Code Samples: http://www.devhut.net
Tuesday, September 6, 2016 2:09 PM -
When you display that memo field on a form, be sure to set the property for Rich Text.
Note that you will never get total fidelity this way. If that is required, leave the email in Outlook, and store a pointer to it in your database. For most applications 90% fidelity is good enough.
-Tom. Microsoft Access MVP
Tuesday, September 6, 2016 3:56 PM -
Hi tekoko,
>>If I import the body text of an outlook email into a memo field , it seems the line-feeds are gone
I made a test with Access 2013 and Outlook 2013. It works correctly at my side.
- Import Outlook to Access
- Setting the field type as Long Text( which is Memo Field before Access 2010)
- Create a Form based on imported table
- The type of TextBox control is Plain Text which is automatically set.
It would be helpful if you could share us your detailed steps.
Best Regards,
Edward
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.Wednesday, September 7, 2016 2:49 AM -
neither a long text or rich text field works
this is my function
Sub SaveEmailErrors(OutlookFolderInInbox As String, aantal As Integer)
Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim SubFolder As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim MyDocPath As String
Dim i As Integer
Dim wsh As Object
Dim fs As Object
Dim TempRst As dao.Recordset
Dim rst As dao.Recordset
Dim aantalmails As Integer
Set db = CurrentDbSet TempRst = CurrentDb.OpenRecordset("tbl_OutlookTemp")
On Error GoTo ThisMacro_errSet ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
Set SubFolder = Inbox.Folders("Markant").Folders("inschrijvingen")
i = Nz(DMax("i", "tbl_outlooktemp"), 0)
' Check subfolder for messages and exit of none found
If SubFolder.Items.Count = 0 Then
Set SubFolder = Nothing
Set Inbox = Nothing
Set ns = Nothing
Exit Sub
End IfFor Each Item In SubFolder.Items
i = i + 1
With TempRst
If Left(Item.Class, 2) = 43 Then
.AddNew
!Subject = Item.Subject
!From = Item.SenderName
!To = Item.To
!Body = Item.Body
!Datesent = Item.SentOn
!EntryID = Item.EntryID
!i = i
!Class = Item.Class
!Parent = Item.Parent
!ReceivedByName = Item.ReceivedByName
!SendUsingAccount = Item.SendUsingAccount
!SenderName = Item.SenderName
!SenderEmailAddress = Item.SenderEmailAddress
!Sender = Item.Sender.Update
Else
.AddNew
!Subject = Item.Subject
!Body = Item.Body
!EntryID = Item.EntryID
!i = i
!conversationID = Item.conversationID
!Class = Item.Class
!Parent = Item.Parent
.Update
End If
End With
Next Item
' Clear memory
ThisMacro_exit:
TempRst.Close
Set TempRst = Nothing
Set SubFolder = Nothing
Set Inbox = Nothing
Set ns = Nothing
Set fs = Nothing
Set wsh = Nothing
Exit Sub' Error information
ThisMacro_err:
'
If Err.Number = 3022 Then
aantalmails = aantalmails - 1
Resume Next
End If
Resume ThisMacro_exitWednesday, September 7, 2016 6:26 AM -
Hi tekoko,
>>neither a long text or rich text field works
What is your Access version? How did you create the table and how did you set long text field? I made a test with below code and steps, it works under Access 2013.
1. Create a new table with Long Text field whose Text Format is Plain Text.
2. Run below code
Sub getOutlook() Dim ns As NameSpace Dim Inbox As MAPIFolder Dim SubFolder As MAPIFolder Dim Item As Object Dim Atmt As Attachment Dim FileName As String Dim MyDocPath As String Dim i As Integer Dim wsh As Object Dim fs As Object Dim TempRst As dao.Recordset Dim rst As dao.Recordset Dim aantalmails As Integer Set db = CurrentDb Set TempRst = CurrentDb.OpenRecordset("ImportOutlook") Set ns = GetNamespace("MAPI") Set Inbox = ns.GetDefaultFolder(olFolderInbox) Set SubFolder = Inbox.Folders("Celeste Li") i = Nz(DMax("ID", "Off"), 0) ' Check subfolder for messages and exit of none found If SubFolder.Items.Count = 0 Then Set SubFolder = Nothing Set Inbox = Nothing Set ns = Nothing Exit Sub End If For Each Item In SubFolder.Items i = i + 1 With TempRst Debug.Print Item.Body If Left(Item.Class, 2) = 43 Then .AddNew !Subject = Item.Subject !Body = Item.Body .Update Else .AddNew !Subject = Item.Subject !Body = Item.Body .Update End If End With Next Item End Sub
3. Check the output in Immdeiate window and check the value in the new table.
Best Regards,
Edward
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- Marked as answer by tekoko10 Thursday, September 8, 2016 7:12 AM
Thursday, September 8, 2016 2:25 AM -
yes , this works it had to do with the plain text ( I changed the file but forgot to change it on the form )Thursday, September 8, 2016 7:13 AM
-
may thanksThursday, September 8, 2016 7:13 AM