none
Problem with automatically downloading emails with polish signs (VBA) RRS feed

  • Question

  • Hello,

    When I try to automatically download email to folder (named with email title) and this email title contain polish letters (for example "ścieżka") I received a following message: "Outlook cannot save or create this file. Make sure that the disk you want to  save the on is not full, write-protected, or damaged." 

    I thought a lot about this problem and I know what is the reason: When I create a new folder with MkDir at computer with mail title, mail title is already without polish letters, for example  C:\XXX\sciezka  not C:\XXX\ścieżka Even in the locals window mail title is without polish letters. The strange part is (which I don't understand) that when macro goes to part with saving mail to path which I show to it, it behaved like this path is with polish letters and mail title also contain them.  So it want to save file at destination: C:\XXX\ścieżka which actually doesn't exist (because it was created like this: C:\XXX\sciezka).   

    So my question is: How I can remove this polish signs when it comes to saving file  with:

     itm.SaveAs Mailpath & ".doc", olDoc

    Or 

    How I can include polish signs in mail title from the beginning when I take it with: topic = itm.Subject 

    Do you know why it is happening like that? Let me now if something is to complicated, or I tell it in unclear way. 

    Thanks for your help,
    Robert



    Wednesday, April 1, 2015 9:45 AM

Answers

  • Hello Robert,

    First of all, I have noticed that you try to save files on the C: drive which requires admin privileges for writing anything. Try to choose another drive. Is that the case?

    I believe the issue is not related to Outlook. Try to create a file using the System.IO namespace classes with polish name programmatically. Do you get any exceptions or errors in that case?

    You can use the System.Text.Encoding class to change the encoding format. Be aware, characters outside of the code page will not be rendered properly. The last resort is to choose another filename.

    Wednesday, April 1, 2015 9:58 AM

All replies

  • Hello Robert,

    First of all, I have noticed that you try to save files on the C: drive which requires admin privileges for writing anything. Try to choose another drive. Is that the case?

    I believe the issue is not related to Outlook. Try to create a file using the System.IO namespace classes with polish name programmatically. Do you get any exceptions or errors in that case?

    You can use the System.Text.Encoding class to change the encoding format. Be aware, characters outside of the code page will not be rendered properly. The last resort is to choose another filename.

    Wednesday, April 1, 2015 9:58 AM
  • Hello, 

    Thank you for answer! I'm sure that is not a problem with saving at disk C (I'm saving like this a lot of emails, and I realized that there are problems only if there are special characters in mail title). When I am making folder C:\ALL\ścieżka1 manually, mail is downloading without any problem.

    I'm pretty new in all this things and I will read about System.IO namespace and System.Text.Encoding soon, for now I don't know what it is. 

    This is part of my macro responsible for creating that folders and downloading emails, maybe you can see here some issues: 

    Option Explicit
    Sub folders()
    Dim Path As String 'this is path for "ALL" folder
    Dim foldname As String ' it will show name of folder
    Public topic As String 'string made from topic of email
        Dim ns As Outlook.NameSpace
        Set ns = Outlook.GetNamespace("MAPI")
        Dim itm As Object
        Dim Path1 As String 'path of email in ALL folder with "/" at the end
        Dim Pathmail As String 'Path1 plus name of email topic
        Dim myolApp As Outlook.Application
        Dim olFolder As Outlook.MAPIFolder
        Set myolApp = CreateObject("Outlook.Application")
        Set olFolder = ns.GetDefaultFolder(olFolderInbox)
        Set olFolder = myolApp.ActiveExplorer.CurrentFolder      
           foldname = olFolder.Name
           removebadmarks foldname, "-" 'going to part of macro which removes bad marks (?/!/%/Chr(34)/…) from folder name
           Dim scfolder As String       
       scfolder = "C:\ALL\" & foldname
            MkDir scfolder 'creating new folder in ALL
    For Each itm In olFolder.Items 'making actions at each email in selected folder
            topic = itm.Subject
           removebadmarks topic, "-" 'removing bad marks from mail topic 
            Path = "C:\ALL\" & foldname & "\" & topic & i
            MkDir Path
            Path1 = Path & "\"
            Pathmail = Path1 & topic
            itm.SaveAs Pathmail & ".doc", olDoc
         Next
    End  Sub
    

     
    Wednesday, April 1, 2015 10:18 AM
  • I'd suggest asking separate questions on new forum threads. Thus, forum readers may recognize questions and answers easily.

    Set ns = Outlook.GetNamespace("MAPI")

    Where did you get the Outlook instance. Is it an Outlook VBA code? If so, there is no need to create a new Application instance:

    > Set myolApp = CreateObject("Outlook.Application")

    Use the Application property provided by the VBA runtime instead.

    > myolApp.ActiveExplorer.CurrentFolder     

    Don't use multiple dots in the single line of code. I always recommend breaking the chain of calls.

    Wednesday, April 1, 2015 10:37 AM