Hi guys i this is jitender, i m having the solution of reading mails from outlook 2003,hope it will help to needy person,
you have to use Outlook Object Model for that.
add in the reference,
microsoft Outlook 11.0 object library.
than u have to referenced outlook redemption this dll will help us to hide security message.
code below
Public
Function PollEmailThroughOutlook()
As Boolean
Dim FilePath
As String
Dim PollMail
As String
Dim objFS As FileStream
Dim objSW As StreamWriter
Dim oInbox
As Outlook.Folders
Dim oTempFolder
As Outlook.MAPIFolder
Dim oFolders
As Outlook.Folders
Dim count As
Integer
Catch ex As Exception
End Try
Dim obj As
Object
Dim AttachmentFile
As String
Dim OFileName
As String
Dim FileName
As String
Dim TextFilePath
As String
Dim sBody As
String
Dim objTxtFile
As FileInfo
For Each attachObject
As Outlook.Attachment
In objMail.Attachments
obj = attachObject.MAPIOBJECT
AttachmentFile = FilePath & attachObject.FileName
Dim objAFile
As FileInfo
objAFile =
New FileInfo(AttachmentFile)
If (objAFile.Exists)
Then
objAFile.Delete()
End If
attachObject.SaveAsFile(AttachmentFile)
FileName = attachObject.FileName.ToString()
OFileName = ExtFileNameFrmExt(FileName)
TextFilePath = FilePath & OFileName &
".txt"
objTxtFile =
New FileInfo(TextFilePath)
If (objTxtFile.Exists)
Then
objTxtFile.Delete()
End If
objFS =
New FileStream(TextFilePath, FileMode.CreateNew, FileAccess.Write)
objSW =
New StreamWriter(objFS)
oSafeItem.Item = objMail
sBody = oSafeItem.Body
objSW.Write(sBody)
objSW.Close()
objFS.Close()
objMail.Move(SubFolder)
i = i - 1
Next attachObject
Next
End If
Catch ex As Exception
End Try
End Function
One more thing i need to told you,we can't do this in C#.
I have created a web application in c# and executed it. in the debug mode that is when i am executing the application in my machine i am able to read the mails, but when i created virtual directory and accessing it from my own computer/system using the
IP instead of locahost its asking for credentials, even if i give my own windows autentication credentials it says not authorized to view the page. I am unable to access it from other systems too..
Will your code can be used to access the outlook mails if we create the virtual directory and access. If so pls let me know.
When I try to add a reference in VS 2005, I cannot find that library in either .net or com objects. anyone have any ideas of where I can get this or find it?
None
0 Points
6 Posts
Read Mails from Outlook 2003 Programmaticaly Without Security Message Shown.
Apr 17, 2007 02:56 AM|pjyadav100|LINK
Hi guys i this is jitender, i m having the solution of reading mails from outlook 2003,hope it will help to needy person,
you have to use Outlook Object Model for that.
add in the reference,
microsoft Outlook 11.0 object library.
than u have to referenced outlook redemption this dll will help us to hide security message.
code below
Public
Function PollEmailThroughOutlook() As Boolean Dim FilePath As String Dim PollMail As String Dim objFS As FileStream Dim objSW As StreamWriter Dim oInbox As Outlook.Folders Dim oTempFolder As Outlook.MAPIFolder Dim oFolders As Outlook.Folders Dim count As IntegerFilePath = ConfigurationSettings.AppSettings(
"FilePath")PollMail = ConfigurationSettings.AppSettings(
"PollMails") TryoApplication = CreateObject(
"Outlook.Application")oNameSpace = oApplication.GetNamespace(
"MAPI")oSafeItem = CreateObject(
"Redemption.SafeMailItem")inbox = oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
TrySavedMailsAttachment = inbox.Parent
oTempFolder = oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
oFolders = oTempFolder.Folders
SavedMailsAttachment = oFolders.Add(PollMail, Outlook.OlDefaultFolders.olFolderInbox)
Catch ex As Exception End TryoInbox = inbox.Folders
SubFolder = inbox.Folders(
"PollMails")count = inbox.Items.Count
Dim objMail As Outlook.MailItem Dim i As Integer If (inbox.Items.Count > 0) Then For i = 0 To countobjMail = oApplication.CreateItem(Outlook.OlItemType.olMailItem)
TryobjMail = inbox.Items(i + 1)
Catch ex As Exception End Try Dim obj As Object Dim AttachmentFile As String Dim OFileName As String Dim FileName As String Dim TextFilePath As String Dim sBody As String Dim objTxtFile As FileInfo For Each attachObject As Outlook.Attachment In objMail.Attachmentsobj = attachObject.MAPIOBJECT
AttachmentFile = FilePath & attachObject.FileName
Dim objAFile As FileInfoobjAFile =
New FileInfo(AttachmentFile) If (objAFile.Exists) ThenobjAFile.Delete()
End IfattachObject.SaveAsFile(AttachmentFile)
FileName = attachObject.FileName.ToString()
OFileName = ExtFileNameFrmExt(FileName)
TextFilePath = FilePath & OFileName &
".txt"objTxtFile =
New FileInfo(TextFilePath) If (objTxtFile.Exists) ThenobjTxtFile.Delete()
End IfobjFS =
New FileStream(TextFilePath, FileMode.CreateNew, FileAccess.Write)objSW =
New StreamWriter(objFS)oSafeItem.Item = objMail
sBody = oSafeItem.Body
objSW.Write(sBody)
objSW.Close()
objFS.Close()
objMail.Move(SubFolder)
i = i - 1
Next attachObject Next End If Catch ex As Exception End Try End FunctionOne more thing i need to told you,we can't do this in C#.
Thanks
Jitender.
Software Developer
India.
VB.Net email
None
0 Points
1 Post
Re: Read Mails from Outlook 2003 Programmaticaly Without Security Message Shown.
Dec 04, 2007 08:37 AM|madhan_singh|LINK
Hi,
I have created a web application in c# and executed it. in the debug mode that is when i am executing the application in my machine i am able to read the mails, but when i created virtual directory and accessing it from my own computer/system using the IP instead of locahost its asking for credentials, even if i give my own windows autentication credentials it says not authorized to view the page. I am unable to access it from other systems too..
Will your code can be used to access the outlook mails if we create the virtual directory and access. If so pls let me know.
Regards,
Madhan
None
0 Points
21 Posts
Re: Read Mails from Outlook 2003 Programmaticaly Without Security Message Shown.
Dec 31, 2007 01:11 PM|EYedwabHome|LINK
When I try to add a reference in VS 2005, I cannot find that library in either .net or com objects. anyone have any ideas of where I can get this or find it?