Outlook Fun With Scriptom

It is soo true that if you work for a startup you end up wearing multiple hats. I work for a very small startup and I wear more hats that the Queen of England. One of those hats is of a Visual Basic developer. Most business applications are not fancy or web two point ooh-y, they usually involve some charts, some graphs, and some integration with Microsoft Office products.

As most script kiddies know, with a little Visual Basic code you can write scripts to open, write, and send emails, generate excel documents, print word documents, and so much more. Fore example, here is a little bit of vbs code to automate the send button (now if you can automate running the script):

Set objOutlook = CreateObject(“Outlook.Application”)
Set objNamespace = objOutlook.GetNamespace(“MAPI”)

‘ Need to have open a new email window for the following
Set objInspector = objOutlook.ActiveInspector
Set objMailItem = objInspector.CurrentItem

‘ Send the email, after the user presses the okay
‘ button on the confirmation dialog
objMailItem.Send

Now, if you want to pop up a message dialog with the subject of the last email you received, just run the following lines of code:

Const olFolderInbox = 6
Const olFolderSentMail = 5

Set objOutlook = CreateObject(“Outlook.Application”)
Set objNamespace = objOutlook.GetNamespace(“MAPI”)

Set objFolder = objNamespace.GetDefaultFolder(olFolderSentMail)
MsgBox “Subject: ” & objFolder.Items.GetLast.Subject

I have a few more example of Visual Basic code manipulating Microsoft Office products here. If you want to run similar COM code but in Java you can do so using Groovy and Scriptom. I have already mentioned Scriptom before so I will refer you to that post.

Technorati Tags: , , , , , , ,

Related posts:

  1. COM Scripting With Groovy
  2. Java Outlook Connector 2.0 Review
  3. Groovy On The JVM
  4. Visual Basic And The Java Platform
  5. Print HTML Using IE

This entry was posted in Java, TechKnow, Visual Basic. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*