locked
importing mails in access body RRS feed

  • Question

  • in my database I import mails that are not send to extract the mailladresses that are wrong.

    in some of the mails the body is returned in all Chinese characters .

    how can I prevent this ?

    Thursday, November 10, 2016 9:31 AM

All replies

  • " I import mails that are not send to extract the mailladresses that are wrong"

    How? We'd need to see your code to be able to offer suggestions.


    Daniel Pineault, 2010-2016 Microsoft MVP Professional Support: http://www.cardaconsultants.com MS Access Tips and Code Samples: http://www.devhut.net

    Thursday, November 10, 2016 2:08 PM
  • ub 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
    DoCmd.SetWarnings False
     
     DoCmd.RunSQL "Delete * from tbl_outlooktemp"
     DoCmd.SetWarnings True
     
     Set db = CurrentDb
     Set TempRst = CurrentDb.OpenRecordset("tbl_OutlookTemp")
        On Error GoTo ThisMacro_err
        Set ns = GetNamespace("MAPI")
        Set Inbox = ns.GetDefaultFolder(olFolderInbox)
        Set SubFolder = Inbox.Folders(OutlookFolderInInbox)
        i = 0
        ' Check subfolder for messages and exit of none found
        If SubFolder.Items.Count = 0 Then
            MsgBox "There are no messages in this folder : " & OutlookFolderInInbox, _
                   vbInformation, "Nothing Found"
            Set SubFolder = Nothing
            Set Inbox = Nothing
            Set ns = Nothing
            Exit Sub
        End If
       
        For 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
    aantal = i
        
        ' 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:
        MsgBox "folder does not exist"
        Resume ThisMacro_exit
    End Sub
    Thursday, November 10, 2016 3:41 PM
  • Hi,

    The code is fine and it works for me. It could successfully retrieve text form Outlook mails no matter in English Character or Chinese.

    According to your description, only some mails return wrong result. I suggest you check these mails. I think it is because they were written in the Chinese characters. If you want to add a filter, you could use Items.Restrict Method (Outlook). Or you could add IF sentence to omit them.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 14, 2016 9:09 AM
  • no it is a normal message from OUTLOOK it self :

    here under you see an example and how the body is returned

    Monday, November 14, 2016 9:28 AM
  • Hi,

    Do only some Delivery Receipt or Read Receipt from Microsoft Outlook fail to return correct content?

    I suggest you test some other mails from Microsoft Outlook and you could forward this mail and check if the body is normal.

    Besides, I think you could omit this kind of mails in your macro.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 16, 2016 9:42 AM
  • but in the body are some mailadresses, I need
    Monday, November 21, 2016 7:47 AM
  • Hi,

    Is the "Diagnostic information for administrators" part also in the mail body?

    If you forward the mail, could you retrieve the correct content?

    If using HTMLbody, could you print out normal content?

    I suggest you print out the email body in the Outlook directly.

    Besides, you could manually import an Email folder in Access and check if the mail body is normal.

    If possible, I suggest you remove the personal information and share the email with us via OneDrive.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 21, 2016 12:06 PM
  • the email is above in the picture.

    what I tried is this , I copied the text of the mail directly in the body -field of the table. dan it works fine.

    so the conclusion is clear, something happens when running the code : the body changes to Chinese characters .

    can it have something to do with ascii or so ?

    Wednesday, February 1, 2017 1:50 AM
  • I downloaded the emails to my laptop , then it works well.

    the program is on a online server, can that have something to do with it ?

    something about Unicode or so ?

    please please help me

    Wednesday, February 1, 2017 11:46 AM
  • I found this on Microsoft ...

    https://support.microsoft.com/en-us/help/2985509/forward-of-ndr-in-outlook-2013-displays-chinese-characters

    can this have something to do with it ?

    Wednesday, February 1, 2017 12:31 PM