Private Sub Application_Startup() Question!!!

Y

Yonah Sudwerts

I had a script that worked, but the computer went uh-oh on me.
The last part of my script writing process that I have from another computer
is:
Private Sub Application_Startup()
Set myOlItems =
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items

End SubBasically, I am running this, so I can deal with emails as they arrive to
Outlook.
But It does not seem to be actually intializing properly. From what I
remember, I use another Sub, something with the words intializing in it...
Any ideas what I used??

Thanks,
Yoni
 
Y

Yonah Sudwerts

I might as well throw in my entire script.
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Dim myOlApp As New Outlook.Application
Public WithEvents myOlItems As Outlook.Items

Private Sub Application_Startup()
Set myOlItems =
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items

End Sub

Private Sub myOlItems_ItemAdd(ByVal Item As Object)
Dim myDestFolder As Outlook.MAPIFolder
Dim count As Integer
Dim lRetVal As Long
Dim strPath As String 'Where to save the files on the computer
Dim addE
Set myAtt = Item.Attachments
'Setting up for If condition on Email Name or Address
addE = Item.SenderEmailAddress
If addE = "(e-mail address removed)" Then
count = myAtt.count
'The If only runs if there is an attachment
If count > 0 Then
'The Following 2 lines Save teh attachment to C:\Telzstone\ Today's Date
strPath = "C:\Telzstone\" & Format(Date, "mm_dd_yyyy") & "\"
On Error Resume Next
MkDir strPath
On Error GoTo 0
strFile = strPath & Format(Item.ReceivedTime, "hh_mm_ss") &
".tiff"
myAtt.Item(1).SaveAsFile strFile
'The Following line prints the Saved File
'lRetVal = ShellExecute(0&, "print", strFile, 0&, 0&, 0&)
'The Following line erases the file, but it doesnt work
'Kill strFile
'The Following line Marks the Email as Read, so it doesnt show that annoying
Bold Number
Item.UnRead = False
'The Following Line will Erase the email
'Item.Delete
strPath = ""
strFile = ""
End If
End If
End Sub
<<<<<<<<<<<<<<<<
 

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