|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
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
|
|||
|
|||
|
I
desperately need help in extracting attachments from MS Outlook emails via VB 6, any help would be surely appreciated. |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
Thanks for the reply bro'.
|
|
#4
|
|||
|
|||
|
I hope you find your answer, I haven't coded Outlook from VB myself.
|
|
#5
|
|||
|
|||
|
found some... now for the tricky part, actually understanding the damn thing, hehehe... thnx again bro'.
|
|
#6
|
|||
|
|||
|
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 |
|
#7
|
|||
|
|||
|
I'm happy you solved it!
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Extracting Attached files from Email |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|