473,385 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

exchange 2003 *Save Attachments*

Hi,

I have a VB.net application that will save attachments to a directory
on my local pc. I need to run this component on our exchange 2003
server and also save the attachments to a local DIR. When the
component is run on the exchange 2003 server a wizard gui is
automatically started which wants to install Outlook 2003. The
component is using mapi to access the default inbox.

What do i need to do to convert this component to run on exchange 2003
server so that Outlook 2003 doesnt need to be installed? Do you have
any suggestions?

here is the code used in the component:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~

Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents btnSave As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.btnSave = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'btnSave
'
Me.btnSave.Location = New System.Drawing.Point(112, 24)
Me.btnSave.Name = "btnSave"
Me.btnSave.TabIndex = 0
Me.btnSave.Text = "SaveNow"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.btnSave)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnSave.Click
SaveAttachments("")
End
End Sub
Public Function SaveAttachments(ByVal PathName As String) As
Boolean
Dim oOutlook As Outlook.Application
Dim oNs As Outlook.NameSpace
Dim oInbox As Outlook.MAPIFolder
Dim oMessage As Outlook.MailItem
Dim oAttachment As Outlook.Attachment
Dim oItems As Outlook.Items
Dim iCtr As Integer
Dim iAttachCnt As Integer
On Error GoTo ErrHandler
GetTempDir()
sPathName = "E:\Temp\"
If sPathName.Substring(sPathName.Length - 1) <> "\" Then
sPathName = sPathName & "\"
If Dir(sPathName, vbDirectory) = "" Then Exit Function
oOutlook = New Outlook.Application
oNs = oOutlook.GetNamespace("MAPI")
oNs.Logon("", "", False, True)
oInbox =
oNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFo lderInbox)
oItems = oInbox.Items
Dim i As Integer
oItems = oItems.Restrict("[Attachment] = true")
'oItems = oItems.Restrict("[Read] = true") 'This will read
'Unread' messages
For i = 1 To oItems.Count
oMessage = oItems.Item(i)
With oMessage.Attachments
iAttachCnt = .Count
If iAttachCnt > 0 Then
For iCtr = 1 To iAttachCnt
.Item(iCtr).SaveAsFile(sPathName &
..Item(iCtr).FileName)
Next iCtr
End If
End With
Next
SaveAttachments = True
Exit Function
ErrHandler:
MsgBox(Err.Description, MsgBoxStyle.Critical, Err.Number & "
" & "bye-bye")
oMessage = Nothing
oInbox = Nothing
oNs = Nothing
oOutlook = Nothing
End Function

Public Function GetTempDir() As String
Dim strDLL As System.Reflection.Assembly
sPathName = strDLL.GetExecutingAssembly().Location
sPathName = sPathName.Substring(0,
sPathName.LastIndexOfAny("\") + 1)
'above gives DIR of \BIN\ dir
GetTempDir = "C:\Scripts\SaveEmailAttachment\"
End Function
Public sPathName As String
End Class
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~

Thank you,
Fish
Nov 21 '05 #1
0 2863

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: mark wheeler via .NET 247 | last post by:
I have a requirement whereby I need to read the contents &attachments of email sent to an account in exchange server2003. The email details (sender, attachment file names, date, etc) areto be stored...
2
by: Joe George | last post by:
Hi there, How to save email attachments, from exchange, using WebDAV in C#.NET? Sample code please................... Thanks for your help. -- Joe George
7
by: Wiebe Tijsma | last post by:
Hi, I'm using C# + webDAV to create a draft message to be sent in a user's Drafts folder. I can create the message successfully, however when I open the message in outlook, it doesn't show...
3
by: mukesh78ae | last post by:
Dear All, With the code below I am able to successfully pull out e-mails by using the sql query defined with the webdav's search method. However, I am very unclear how to pull the attachments from...
4
by: KDawg44 | last post by:
Hi, I am frustrated with my users who send large files around the office instead of using the network shares. For instance, this is one of many emails I have sent around: "If you take the...
5
by: =?Utf-8?B?RGF2aWRF?= | last post by:
Hi, I have to write an application that run once a day that can read all new mails on an exchange special inbox. Then I have to get the subject,attachments,date etc from each email . How can I...
2
by: =?Utf-8?B?RGF2aWRF?= | last post by:
Hi, I try to connect to Exchange server using MAPI. I need to access a special user inbox and read all his new mails. The code I wrote work good, but I get my inbox instead of the user I need....
2
by: Salad | last post by:
In A2003 one can create a linked table using File/GetExternalData/Link/Exchange(). It's a nice feature but by and large fairly useless if I am reading the table structure correctly. The From &...
2
by: LVP | last post by:
Hi Everyone, I am looking to get emails from a Public Folder on our internal server using a filter from exchange server 2007 extract attachments tag or set the status on each email so I don't...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.