none
using an INI file in Outlook addins RRS feed

  • Question

  • Is that possible`?

    I have an Outlook addin that works just fine, i have a Windows installer file with the addin that can be installed directly on the machine running Outlook 2010, and it works just fine as well.

    I would like to know and SEE an example of using an INI file with this addin so i can set for example a folder address to something else if it is possible.

    right now my addin puts attachments to C:\attachments(hardcoded) but i would like to have the possibility to let it point to some other folder for example B:\TestAttachments without rewriting my addin code in VS

    So does anyone have an example of this with a string variable in it that could be modified from an INI file

    Addin is written in VS 2010 and is used in Outlook 2010 ;o)

    Thanks in advance ;o)

    Tuesday, March 26, 2013 1:40 PM

Answers

  • If you store any data, do not use any custom folders off the root drive (C;\) - chances are the user will not have access rights to create folders and files there.

    Use the AppData folder - Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

    It is also a good idea to store profile specific data (e.g. entry ids) in the profile itself - that data is usually stored as a hidden item in one of the default folder, for example an Inbox. Outlook Object Model exposes that through the MAPIFolder.GetStorage method - see http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mapifolder.getstorage.aspx


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Tuesday, March 26, 2013 1:56 PM
  • I am not sure what you mean by "is it possible for me to set a path to my attachment folder that way".

    It is your code that calls Attachment.SaveAsFile, right? You can specify any path you want.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Tuesday, March 26, 2013 2:22 PM
  • The attachments temp folder location is stored in the registry and read by Outlook on startup. It can be changed by changing he folder path in the registry when Outlook isn't running.
     
    HKCU\Software\Microsoft\Office\15.0\Outlook\Security\OutlookSecureTempFolder is the registry path for that for Outlook 2013. Change the "15.0" to the appropriate version for other versions of Outlook.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "øv" <=?utf-8?B?w7h2?=> wrote in message news:a9d0b7d9-00b7-4dcb-8291-1381497a6027...

    I have a colleague that would like to be able to set the path to the attachment folder from D:\attachments to B or E or F:\Attachments without modifying the code..

    He said it could possibly be done by using an INI file that points to the attachments folder and the program could have a variable named "dim attachmentFolder as string"  and make it read the folderpath in an INI file, i have never used INI files before thats why im not sure if it is even possible...

    The INI files i have seen has startup parameters like a path to C:\Program files\CompanyName\TheSoftware.exe

    i think thats the best i can describe it... :O)


    Ken Slovak MVP - Outlook
    Tuesday, March 26, 2013 6:42 PM
    Moderator

All replies

  • If you store any data, do not use any custom folders off the root drive (C;\) - chances are the user will not have access rights to create folders and files there.

    Use the AppData folder - Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

    It is also a good idea to store profile specific data (e.g. entry ids) in the profile itself - that data is usually stored as a hidden item in one of the default folder, for example an Inbox. Outlook Object Model exposes that through the MAPIFolder.GetStorage method - see http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mapifolder.getstorage.aspx


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Tuesday, March 26, 2013 1:56 PM
  • Thank you for your quick reply ;o)

    I just wrote C:\ by mistake, right now it´s actually on D:\attachments

    I Will look into that: Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)

    I am not familiar with it at all, is it possible for me to set a path to my attachment folder that way? because that would actually solve everything for me ;o)

    By the way, it will only be 1 or 2 persons that should have the ability to change the pointer to the folder.

    Tuesday, March 26, 2013 2:14 PM
  • I am not sure what you mean by "is it possible for me to set a path to my attachment folder that way".

    It is your code that calls Attachment.SaveAsFile, right? You can specify any path you want.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Tuesday, March 26, 2013 2:22 PM
  • I have a colleague that would like to be able to set the path to the attachment folder from D:\attachments to B or E or F:\Attachments without modifying the code..

    He said it could possibly be done by using an INI file that points to the attachments folder and the program could have a variable named "dim attachmentFolder as string"  and make it read the folderpath in an INI file, i have never used INI files before thats why im not sure if it is even possible...

    The INI files i have seen has startup parameters like a path to C:\Program files\CompanyName\TheSoftware.exe

    i think thats the best i can describe it... :O)

    Tuesday, March 26, 2013 6:06 PM
  • The attachments temp folder location is stored in the registry and read by Outlook on startup. It can be changed by changing he folder path in the registry when Outlook isn't running.
     
    HKCU\Software\Microsoft\Office\15.0\Outlook\Security\OutlookSecureTempFolder is the registry path for that for Outlook 2013. Change the "15.0" to the appropriate version for other versions of Outlook.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "øv" <=?utf-8?B?w7h2?=> wrote in message news:a9d0b7d9-00b7-4dcb-8291-1381497a6027...

    I have a colleague that would like to be able to set the path to the attachment folder from D:\attachments to B or E or F:\Attachments without modifying the code..

    He said it could possibly be done by using an INI file that points to the attachments folder and the program could have a variable named "dim attachmentFolder as string"  and make it read the folderpath in an INI file, i have never used INI files before thats why im not sure if it is even possible...

    The INI files i have seen has startup parameters like a path to C:\Program files\CompanyName\TheSoftware.exe

    i think thats the best i can describe it... :O)


    Ken Slovak MVP - Outlook
    Tuesday, March 26, 2013 6:42 PM
    Moderator