Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 22nd, 2004, 10:20 AM
SloppyGoat SloppyGoat is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 2 SloppyGoat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Outlook Macro help needed

Can someone take a look at this? The problem I'm having is, sometimes it misses the files in some messages. I think it may be just running too fast, maybe?

This goes in "ThisOutlookSession"

Code:
Private Sub Application_NewMail()
  On Error GoTo GetAttachments_err
	 Dim Inbox As MAPIFolder
	 Dim email As MailItem
	 Dim Atmt As Attachment
	 Dim i As Integer, Count As Integer
	 Const FileName = "D:\Program Files\ATS M5000\To WordScript\"
  Set Inbox = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
  i = 0
  If Inbox.Items.Count = 0 Then Exit Sub
  'cycle through emails
  For Each email In Inbox.Items
	If email.Subject = "Dictation" Then
	  If email.Attachments.Count > 0 Then
		For Count = email.Attachments.Count To 1 Step -1
		  Set Atmt = email.Attachments.Item(Count)
		  If LCase(Right(Atmt.FileName, 3)) = "wav" Or _
			  LCase(Right(Atmt.FileName, 3)) = "xml" Then
			Atmt.SaveAsFile (FileName & Atmt.FileName)
			Atmt.Delete
			i = i + 1
		  End If
		Next Count
		email.Save
	  End If
	End If
  Next email
  If i > 0 Then
	MsgBox "  " & i & " attached files were found." _
	   & vbCrLf & "They have been copied to your work folder." _
	   & vbCrLf & vbCrLf & "Have a nice day.", vbInformation, "Finished!"
  End If
GetAttachments_exit:
 Set Atmt = Nothing
 Set email = Nothing
 Exit Sub
GetAttachments_err:
 MsgBox "An unexpected error has occurred." _
	  & vbCrLf & "Please note and report the following information." _
	  & vbCrLf & "Macro Name: GetAttachments" _
	  & vbCrLf & "Error Number: " & Err.Number _
	  & vbCrLf & "Error Description: " & Err.Description _
	  , vbCritical, "Error!"
 Resume GetAttachments_exit
End Sub

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Outlook Macro help needed


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT