Replace olFolderContacts for Sharepoint lists in Outlook

A

Alexnts

Good morning to all :)

I am using this piece of code here
http://www.vboffice.net/sample.html?mnu=2&pub=6&lang=en&smp=32&cmd=showitem
to massively change the internet format field of Sharepoint Contacts in
Outlook.
It works like a charm in the local contact list but not in the cached
Sharepoint lists.
The problem is at this line i think.

Set Items = Session.GetDefaultFolder(olFolderContacts).Items

How can i set the script to selectand workon the Sharepoint lists(local
cached) instead of the local lists?

Best Regards.
 
S

Sue Mosher [MVP]

To get a non-default folder, you need to walk the folder hierarchy using the
Folders collections or use a function that does that for you. For examples,
see:

http://www.outlookcode.com/codedetail.aspx?id=628 - uses a folder path
string
http://www.outlookcode.com/codedetail.aspx?id=492 - searches for a folder by
name

What you're trying to do may not work, though, because (a) SharePoint simply
doesn't support all the fields and functionality of Outlook contacts and (b)
the synchronization process may overwrite whatever changes you make in the
local cached copy of the SharePoint list. I would make the change on an
individual contact and see what happens at the next sync, before making an
investment in coding something bigger.
 
A

Alexnts

Hello Sue.
Thank you for your answer. :)
I am not trying to change any field on sharepoint directly.
I am trying to change the Internet format on the cached sharepoint list.
My whole scenario is this
www.tinyurl.com/defaultrtf (outlook contacts part of this forum)
Using Outlook 2007 the changes i make doesn't alter after a synchronization.
Outlook by default sets RTF to every imported contact (the imports may be
from Sharepoint or ActiveSync.It doesn't matter)
Unfortunately this is a setting that overrides the global mail format under
Outlook and produces winmail.dat attachements to every contact not using
Outlook. (yeah what a mess...) :)

A note about the second link that searches for a folder by name.
Unfortunately my programming skills are almost a joke, and i can't make it
work.
I guess that this code runs under ThisOutlookSession (Alt+F11).Right?
Also i can't seem to find the place where i insert the argument's name.
(' Arguments: strFolderName = name of folder to search for)
In which part of the code i enter my folder's name?
Let's say the folder's name is DefaultRTF.

Excuse my funny questions and my lousy English.
Best Regards.
 
S

Sue Mosher [MVP]

If you've already tested to see whether changes persist after a sync, that's
great. You should then have everything you need now to complete your
project.

The code sample at http://www.outlookcode.com/codedetail.aspx?id=492 is
designed as a generic function that can be used in many different
environments. To use it in Outlook VBA, either in ThisOutlookSession or
another module, you would want to change this statement:

Set objApp = CreateObject("Outlook.Application")

to

Set objApp = Application

in order to use the intrinsic Application object that Outlook VBA exposes.

The first comment on the code sample is an example of its usage.
GetFolderByName() is a function, so you pass the folder name to it as you
would any other function argument, e.g. MyFunction(myargument). Put it in
your code where you need to return the folder to work on.
 
A

Alexnts

Thank you for your answer Sue!

Regarding GetFolderByName, from what i can understand i have to create a Sub
that calls this function.Right?

The code that rockman posts (in the first post) to run behind a button
doesn't seem work on me. (nothing happens).
I have also tried to test the code that Emory Brown posts in your " New
and improved GetFolder() function" posts but the debugger stops on "Dim regex
As RegExp"

Argghhh...
I really thought that i could bypass this bug of Outlook (regarding the
dafaultrtf) without having special programming skills.

Best Regards.
Alex
 
S

Sue Mosher [MVP]

Yes, your scenario needs a macro, which is a public, argumentless
subroutine. What happens when you step through the demo procedure in the
debugger? Have you checked the VBA basics at
http://outlookcode.com/article.aspx?id=49?

If you're not using regular expressions in your project, you don't need that
Dim statement from the other sample or any of the code that references
regex.

In general, you're going to have to understand the code in order to use it.
That doesn't mean "special" programming skills in your scenario, just basic
skills and a willingness to spend some time learning.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 

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