dcsimg
December 6, 2016
Hot Topics:

Making Microsoft Outlook Useful - Part 1

  • November 19, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

So you think youre ready to play around with messages eh? Well, true, you probably are. Messages are referred to as items in Outlook, as you can also have appointments & notes etc. For now, well be dealing with the items located within the Inbox folder.

The next snippet of code shows you how to simple create a message, write a short message, and save it in the Drafts folder:

Private Sub Form_Load()  Dim objOutlook As New Outlook.Application  Dim objNameSpace As Outlook.NameSpace  Dim objInbox As MAPIFolder  Dim objMail As MailItem      'Get the MAPI reference  Set objNameSpace = objOutlook.GetNamespace("MAPI")    'Pick up the Inbox  Set objInbox = objNameSpace.GetDefaultFolder(olFolderInbox)    Set objMail = objInbox.Items.Add  With objMail    .Subject = "Well done"    .Body = "This article is great!"    .To = "sam@vbsquare.com"    .Save  End WithEnd Sub

If you look closely at the code youll see that Ive been rather cheeky with the body and subject lines, so to get your own back you can run the next piece of code to delete my ego booster!

Private Sub Form_Load()  Dim objOutlook As New Outlook.Application  Dim objNameSpace As Outlook.NameSpace  Dim objDrafts As MAPIFolder  Dim objMail As MailItem      'Get the MAPI reference  Set objNameSpace = objOutlook.GetNamespace("MAPI")    'Pick up the Drafts folder  Set objDrafts = objNameSpace.GetDefaultFolder(olFolderDrafts)    Set objMail = objDrafts.Items("Well done")  objMail.DeleteEnd Sub

Right, thats just about it for the first part in this series! In part 2 youll learn how to:

  • Filter emails as you read them in through different criteria
  • Build a program which allows you to:
  • Read in messages from a folder
  • Filter duplicates & blanks
  • Apply a date criteria
  • Locate the email details
  • Write them to a file

See you again soon for some more exciting Outlook programming!

Sam





Page 3 of 3



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel