Cyberiafreak

"Fortunate are those who take the first steps.” ― Paulo Coelho

Outlook:VBA#1 [How to move older mails to archive folders using code]

Private Sub Application_Startup()

Dim objOutlook As Outlook.Application
Dim objInboxFolder As Outlook.MAPIFolder
Dim myNewFolder As Outlook.Folder
Dim objNamespace As Outlook.NameSpace
Set objOutlook = Application
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objInboxFolder = objNamespace.GetDefaultFolder(olFolderInbox)
Set newFolder = objInboxFolder.Folders.Add("Test-Archived-Jan2014")
Dim movedItemCount As Long

For intCount = objInboxFolder.Items.Count To 1 Step -1
Set objVariant = objInboxFolder.Items.Item(intCount)
DoEvents
If objVariant.Class = olMail Then
intDateDiff = DateDiff("d", objVariant.SentOn, Now)
If intDateDiff > 10 Then
' Set objArchiveFolder = objNamespace.Folders("maheshk@keepmovin.com"). _
' Folders("Inbox").Folders("Old")
objVariant.Move newFolder
movedItemCount = movedItemCount + 1
Set objArchiveFolder = Nothing
End If
End If
Next
MsgBox "Done, archived:#" & movedItemCount

End Sub

Advertisements

January 31, 2014 Posted by | Outlook, VBA | Leave a comment

Design scenarios from – .NET Technology Guide for Business Applications.pdf

I highly recommend this pdf for anyone who is looking for design guide in .NET.

Note: It also talks about Silverlight scope, migration & suggestions. Get one from here – http://www.microsoft.com/net/nettechnologyguidance

.NET Technology Guide for Business Applications

January 6, 2014 Posted by | .NET General | Leave a comment

How to attach Visual studio dynamically

I never thought this would be so easy with this couple of statements. All these days, I used to put a hard coded message box thrown up and then try to attach manually VS by selecting that new process.  But this one is very useful if you want to do automatically break in VS.

if (!Debugger.IsAttached)
 Debugger.Launch();
 Debugger.Break();

This would be useful if you are debugging multiple process in the Visual Studio – Ley say you HelloWorld.exe is creating a new exe LogViewer.exe and yourself want to debug end to end all in same VS.  More at MSDN- http://goo.gl/lKJcUh

January 3, 2014 Posted by | .NET General | 1 Comment

   

%d bloggers like this: