VB and Outlook

W

Will Smith

I have a wsh script that takes a message from the inbox,
saves the attachment to a network location and closes out
of Outlook. I need to figure out how to move the message
to a subfolder and send out a success email and THEN close
Outlook. Here is the actual code I am using right now:

<job>
<script language="VBScript">
dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objOL = WScript.CreateObject ("Outlook.Application")
Set MAPI = objOL.GetNamespace("MAPI")
Set myStore = MAPI.Folders("Mailbox - Tunisia Information")
Set Folder = myStore.Folders("Inbox")
For Each myItem In Folder.Items
For Each att In myItem.Attachments
att.SaveAsFile "\\naslc03
\data\TunisiaProdData\" & att.Filename
Next
Next
objOL.quit
</script>
</job>

Any help would be greatly appreciated. Thanks.
 
B

Bill James

For Each myItem In Folder.Items
For Each att In myItem.Attachments
att.SaveAsFile "\\naslc03
\data\TunisiaProdData\" & att.Filename
Next

' New code below. This assumes that have
' a subfolder called "MySubFolder" in
' your Inbox folder... You get the idea.
myItem.Move myStore.Folders
("Inbox").Folders("MySubFolder")
mySendRoutine()
Next

'This routine will invoke the Email security dialog...
Sub mySendRoutine()
Dim theMailItem

Set theMailItem = WScript.CreateObject
("Outlook.NewMailItem")
With theMailItem
.To = "(e-mail address removed)"
.Subject = "Your subject"
.Body = "Successful message here."
' If you want HTML email use this instead:
' .HTMLBody = "<html><body>Message
here</body></html>"
.Send
End With
Set theMailItem = Nothing
End Sub

Disclaimer: Please check for typos and possible syntax
errors!
 

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