<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Look for and create folders programmatically in Outlook</title>
	<atom:link href="http://www.codeforexcelandoutlook.com/blog/2008/12/look-for-and-create-folders-programmatically-in-outlook/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codeforexcelandoutlook.com/blog/2008/12/look-for-and-create-folders-programmatically-in-outlook/</link>
	<description>Automation and VBA code for Microsoft® Excel and Outlook</description>
	<lastBuildDate>Thu, 29 Jul 2010 10:47:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: JP</title>
		<link>http://www.codeforexcelandoutlook.com/blog/2008/12/look-for-and-create-folders-programmatically-in-outlook/#comment-2740</link>
		<dc:creator>JP</dc:creator>
		<pubDate>Thu, 22 Jul 2010 22:16:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.codeforexcelandoutlook.com/blog/?p=279#comment-2740</guid>
		<description>The code I posted will only create Mail-type folders. You would need to change this line:

[cc lang=&#039;vb&#039;]Set olInbox = olNS.GetDefaultFolder(olFolderContacts)[/cc]

Then in my sample code, &quot;MyFolder&quot; would point to your new Contacts folder:

[cc lang=&#039;vb&#039;]Set MyFolder = CreateSubFolder(&quot;My Folder&quot;)[/cc]

All you would do then is use the Folder.Items.Add method to add a new contact to the new folder:

[cc lang=&#039;vb&#039;]MyFolder.Items.Add[/cc]</description>
		<content:encoded><![CDATA[<p>The code I posted will only create Mail-type folders. You would need to change this line:</p>
<div class="codecolorer-container vb default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:630px;"><div class="vb codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000080;">Set</span> olInbox = olNS.GetDefaultFolder(olFolderContacts)</div></div>
<p>Then in my sample code, "MyFolder" would point to your new Contacts folder:</p>
<div class="codecolorer-container vb default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:630px;"><div class="vb codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000080;">Set</span> MyFolder = CreateSubFolder(<span style="color: #800000;">&quot;My Folder&quot;</span>)</div></div>
<p>All you would do then is use the Folder.Items.Add method to add a new contact to the new folder:</p>
<div class="codecolorer-container vb default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:630px;"><div class="vb codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">MyFolder.Items.Add</div></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: diya</title>
		<link>http://www.codeforexcelandoutlook.com/blog/2008/12/look-for-and-create-folders-programmatically-in-outlook/#comment-2738</link>
		<dc:creator>diya</dc:creator>
		<pubDate>Thu, 22 Jul 2010 21:01:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.codeforexcelandoutlook.com/blog/?p=279#comment-2738</guid>
		<description>hey hi i am very new, wanted to add contacts in my new folder but unable to do so,

please help me !</description>
		<content:encoded><![CDATA[<p>hey hi i am very new, wanted to add contacts in my new folder but unable to do so,</p>
<p>please help me !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JP</title>
		<link>http://www.codeforexcelandoutlook.com/blog/2008/12/look-for-and-create-folders-programmatically-in-outlook/#comment-1755</link>
		<dc:creator>JP</dc:creator>
		<pubDate>Thu, 07 May 2009 03:03:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.codeforexcelandoutlook.com/blog/?p=279#comment-1755</guid>
		<description>I&#039;m still trying to nail down the exact syntax, but it would be something like

[cc lang=&#039;vb&#039;]
Dim vw As View
Set vw = CreateSubFolder.Views.Add(&quot;My New View&quot;, olTableView, olViewSaveOptionAllFoldersOfType)
[/cc]

Actually setting the folder to that view seems to be a moving target.</description>
		<content:encoded><![CDATA[<p>I'm still trying to nail down the exact syntax, but it would be something like</p>
<div class="codecolorer-container vb default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:630px;"><div class="vb codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000080;">Dim</span> vw <span style="color: #000080;">As</span> View<br />
<span style="color: #000080;">Set</span> vw = CreateSubFolder.Views.Add(<span style="color: #800000;">&quot;My New View&quot;</span>, olTableView, olViewSaveOptionAllFoldersOfType)</div></div>
<p>Actually setting the folder to that view seems to be a moving target.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gary</title>
		<link>http://www.codeforexcelandoutlook.com/blog/2008/12/look-for-and-create-folders-programmatically-in-outlook/#comment-1754</link>
		<dc:creator>Gary</dc:creator>
		<pubDate>Wed, 06 May 2009 14:15:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.codeforexcelandoutlook.com/blog/?p=279#comment-1754</guid>
		<description>Correct, but is there a way to do that in VBA?
I would guess something like

[cc lang=&#039;vb&#039;]Function CreateSubFolder(strFolder As String, blnForSent as Boolean) As Outlook.MAPIFolder
&#039; assumes folder doesn&#039;t exist, so only call if calling sub knows that
&#039; the folder doesn&#039;t exist; returns a folder object to calling sub
&#039; Have calling sub set blnForSent = True for folder to display &#039;To&#039; and &#039;Sent&#039; fields
&#039;                      blnForSent = False for folder to display &#039;From&#039; and &#039;Received&#039; fields
Dim olApp As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olInbox As Outlook.MAPIFolder
Dim olFldr As Outlook.MAPIFolder


Set olApp = Outlook.Application
Set olNS = olApp.GetNamespace(&quot;MAPI&quot;)
Set olInbox = olNS.GetDefaultFolder(olFolderInbox)

Set olFldr = olInbox.Folders.Add(strFolder)


If blnForSent Then
  &#039;olFldr.CurrentView.???
End If

Set CreateSubFolder = olFldr

ExitProc:
Set olFldr = Nothing
Set olInbox = Nothing
Set olNS = Nothing
Set olApp = Nothing
End Function[/cc]</description>
		<content:encoded><![CDATA[<p>Correct, but is there a way to do that in VBA?<br />
I would guess something like</p>
<div class="codecolorer-container vb default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:630px;"><div class="vb codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000080;">Function</span> CreateSubFolder(strFolder <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, blnForSent <span style="color: #000080;">as</span> <span style="color: #000080;">Boolean</span>) <span style="color: #000080;">As</span> Outlook.MAPIFolder<br />
<span style="color: #008000;">' assumes folder doesn't exist, so only call if calling sub knows that<br />
</span><span style="color: #008000;">' the folder doesn't exist; returns a folder object to calling sub<br />
</span><span style="color: #008000;">' Have calling sub set blnForSent = True for folder to display 'To' and 'Sent' fields<br />
</span><span style="color: #008000;">' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;blnForSent = False for folder to display 'From' and 'Received' fields<br />
</span><span style="color: #000080;">Dim</span> olApp <span style="color: #000080;">As</span> Outlook.Application<br />
<span style="color: #000080;">Dim</span> olNS <span style="color: #000080;">As</span> Outlook.Namespace<br />
<span style="color: #000080;">Dim</span> olInbox <span style="color: #000080;">As</span> Outlook.MAPIFolder<br />
<span style="color: #000080;">Dim</span> olFldr <span style="color: #000080;">As</span> Outlook.MAPIFolder<br />
<br />
<br />
<span style="color: #000080;">Set</span> olApp = Outlook.Application<br />
<span style="color: #000080;">Set</span> olNS = olApp.GetNamespace(<span style="color: #800000;">&quot;MAPI&quot;</span>)<br />
<span style="color: #000080;">Set</span> olInbox = olNS.GetDefaultFolder(olFolderInbox)<br />
<br />
<span style="color: #000080;">Set</span> olFldr = olInbox.Folders.Add(strFolder)<br />
<br />
<br />
<span style="color: #000080;">If</span> blnForSent <span style="color: #000080;">Then</span><br />
&nbsp; <span style="color: #008000;">'olFldr.CurrentView.???<br />
</span><span style="color: #000080;">End</span> <span style="color: #000080;">If</span><br />
<br />
<span style="color: #000080;">Set</span> CreateSubFolder = olFldr<br />
<br />
ExitProc:<br />
<span style="color: #000080;">Set</span> olFldr = <span style="color: #000080;">Nothing</span><br />
<span style="color: #000080;">Set</span> olInbox = <span style="color: #000080;">Nothing</span><br />
<span style="color: #000080;">Set</span> olNS = <span style="color: #000080;">Nothing</span><br />
<span style="color: #000080;">Set</span> olApp = <span style="color: #000080;">Nothing</span><br />
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></div></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: JP</title>
		<link>http://www.codeforexcelandoutlook.com/blog/2008/12/look-for-and-create-folders-programmatically-in-outlook/#comment-1753</link>
		<dc:creator>JP</dc:creator>
		<pubDate>Tue, 05 May 2009 22:38:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.codeforexcelandoutlook.com/blog/?p=279#comment-1753</guid>
		<description>Gary,
Right-click on one of the fields and select &quot;Field Chooser&quot;, you can add those fields back in.</description>
		<content:encoded><![CDATA[<p>Gary,<br />
Right-click on one of the fields and select "Field Chooser", you can add those fields back in.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gary</title>
		<link>http://www.codeforexcelandoutlook.com/blog/2008/12/look-for-and-create-folders-programmatically-in-outlook/#comment-1752</link>
		<dc:creator>Gary</dc:creator>
		<pubDate>Tue, 05 May 2009 15:56:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.codeforexcelandoutlook.com/blog/?p=279#comment-1752</guid>
		<description>That&#039;s fine if you&#039;re going to use it to keep mail items that you recieve. What if you use it to keep mail items you&#039;ve sent? When you click on the folder, it has &#039;From&#039; and &#039;Recieved&#039; fields. How do you modify the folder after adding it so &#039;To&#039; and &#039;Sent&#039; fields are shown instead?</description>
		<content:encoded><![CDATA[<p>That's fine if you're going to use it to keep mail items that you recieve. What if you use it to keep mail items you've sent? When you click on the folder, it has 'From' and 'Recieved' fields. How do you modify the folder after adding it so 'To' and 'Sent' fields are shown instead?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JP</title>
		<link>http://www.codeforexcelandoutlook.com/blog/2008/12/look-for-and-create-folders-programmatically-in-outlook/#comment-1751</link>
		<dc:creator>JP</dc:creator>
		<pubDate>Mon, 09 Feb 2009 17:00:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.codeforexcelandoutlook.com/blog/?p=279#comment-1751</guid>
		<description>Glad to help, Reid. 8)</description>
		<content:encoded><![CDATA[<p>Glad to help, Reid. <img src='http://www.codeforexcelandoutlook.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reid Parker</title>
		<link>http://www.codeforexcelandoutlook.com/blog/2008/12/look-for-and-create-folders-programmatically-in-outlook/#comment-1750</link>
		<dc:creator>Reid Parker</dc:creator>
		<pubDate>Mon, 09 Feb 2009 00:36:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.codeforexcelandoutlook.com/blog/?p=279#comment-1750</guid>
		<description>That was EXACTLY the piece of code I was looking for. Thanks very much for posting it!</description>
		<content:encoded><![CDATA[<p>That was EXACTLY the piece of code I was looking for. Thanks very much for posting it!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
