SunQuest
 
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old May 26th, 2004, 04:31 AM
procrastinatorX procrastinatorX is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 13 procrastinatorX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 21 sec
Reputation Power: 0
Exclamation Extracting Attached files from Email

I desperately need help in extracting attachments from
MS Outlook emails via VB 6, any help would be surely appreciated.

Reply With Quote
  #2  
Old May 27th, 2004, 12:48 AM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 18 h 33 m 48 sec
Reputation Power: 180
One place to find outlook programming help is www.slipstick.com
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old May 27th, 2004, 04:22 AM
procrastinatorX procrastinatorX is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 13 procrastinatorX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 21 sec
Reputation Power: 0
Thumbs up

Thanks for the reply bro'.

Reply With Quote
  #4  
Old May 27th, 2004, 01:37 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 18 h 33 m 48 sec
Reputation Power: 180
I hope you find your answer, I haven't coded Outlook from VB myself.

Reply With Quote
  #5  
Old May 27th, 2004, 10:05 PM
procrastinatorX procrastinatorX is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 13 procrastinatorX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 21 sec
Reputation Power: 0
found some... now for the tricky part, actually understanding the damn thing, hehehe... thnx again bro'.

Reply With Quote
  #6  
Old May 28th, 2004, 04:28 AM
procrastinatorX procrastinatorX is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 13 procrastinatorX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 21 sec
Reputation Power: 0
Got It!!!

And now...... With carefull examination and 5 cups of realy strong coffee later here it is.
(Didnt actually author the code but it was a hell of time finding it, So I'm posting it here
in case I lose it again.)



Public Sub StripAttachments()
Dim objOL As Outlook.Application
Dim objMsg As Object
Dim objAttachments As Outlook.Attachments
Dim objSelection As Outlook.Selection
Dim objItem As Outlook.MailItem

Dim myNamespace As Outlook.NameSpace

Dim i As Long
Dim lngCount As Long
Dim strFile As String
Dim strFolder As String

On Error Resume Next

' Instantiate an Outlook Application object.
Set objOL = CreateObject("Outlook.Application")
' Get the collection of selected objects.
'Set objSelection = objOL.ActiveExplorer.Activate

Set myNamespace = objOL.GetNamespace("MAPI")

Set objOL.ActiveExplorer.CurrentFolder = _
myNamespace.GetDefaultFolder(olFolderInbox).items( "Sending Mail from VB")

'myNamespace.GetDefaultFolder (olFolderInbox) '.Name = ""

Set objSelection = objOL.ActiveExplorer.Selection

' Get the Temp folder.
strFolder = GetTempDir()
If strFolder = "" Then
MsgBox "Could not get Temp folder", vbOKOnly
GoTo ExitSub
End If

' dont include this
'==========================
' objSelection.Class = olMail
' Set objAttachments = objMsg.Attachments
' lngCount = objAttachments.count
'
' If lngCount < 1 Then
'
'
'
' End If

'==========================



' Check each selected item for attachments.
' If attachments exist, save them to the Temp
' folder and strip them from the item.



For Each objMsg In objSelection
' This code only strips attachments from mail items.
If objMsg.Class = olMail Then
' Get the Attachments collection of the item.
Set objAttachments = objMsg.Attachments

lngCount = objAttachments.count

If lngCount > 0 Then
' We need to use a count down loop for
' removing items from a collection. Otherwise,
' the loop counter gets confused and only every
' other item is removed.

For i = lngCount To 1 Step -1

' Save attachment before deleting from item.
' Get the file name.
strFile = objAttachments.Item(i).FileName
' Combine with the path to the Temp folder.
strFile = strFolder & strFile
' Save the attachment as a file.
objAttachments.Item(i).SaveAsFile strFile
' Delete the attachment.
objAttachments.Item(i).Delete
Next i
End If
objMsg.Save
End If
Next

ExitSub:
Set objAttachments = Nothing
Set objMsg = Nothing
Set objSelection = Nothing
Set objOL = Nothing
End Sub

Reply With Quote
  #7  
Old May 28th, 2004, 01:14 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 18 h 33 m 48 sec
Reputation Power: 180
I'm happy you solved it!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Extracting Attached files from Email


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