PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook VBA Programming Private Sub Application_Startup() Question!!!

Reply

Private Sub Application_Startup() Question!!!

 
Thread Tools Rate Thread
Old 07-03-2005, 11:34 AM   #1
Yonah Sudwerts
Guest
 
Posts: n/a
Default Private Sub Application_Startup() Question!!!


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 Sub
>>>>>>

Basically, 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


  Reply With Quote
Old 07-03-2005, 11:38 AM   #2
Yonah Sudwerts
Guest
 
Posts: n/a
Default Re: Private Sub Application_Startup() Question!!!

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 = "netvision_community@netvision.net.il" 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
<<<<<<<<<<<<<<<<


"Yonah Sudwerts" <massuds2000@yahoo.com> wrote in message
news:422c3c2f$0$13492$9a6e19ea@unlimited.newshosting.com...
>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 Sub
>>>>>>>

> Basically, 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
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off