TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Add Msg File to PST
Kapil Soni
Sep 18, 2013
17.9
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
Add msg file to or email to pst in outlook using Microsoft.Office.Interop.Outlook.
To Add physical MSG files to PST and generate PST we need to follow below steps:
Add Com library Microsoft.Office.interop.outlook
Create object of COM Object MailItem,Namespace,Application
ns(object of namespace) = app(object of Applciation).GetNamespace("MAPI")
ns.AddStoreEx(newPstFileLocation, OlStoreType.olStoreUnicode)
For Each store As Store In ns.Session.Stores
If store.FilePath = newPstFileLocation Then
newPST = store
End If
Next
Object of MAPI Folder Ex: oFolder
oFolder = newPST.GetRootFolder
.mail = CType(ns.Session.OpenSharedItem(filetobeprocessed), MailItem)
mail.Move(folderInbox)
folderInbox is object of Simple inbox folder and we are adding moving files to folderInbox.
Add msg file to PST
Next Recommended Reading
Creating Excel File using Interop Services