| Posted: 09 August 2006 at 2:19am | IP Logged
|
|
|
You have to get Redemption Outlook dll to convert into msg formats. After installing the Redemption, you can use the following code. Please note, emlPath should contains the valid eml file path which was saved already using ostrosoft component or some others. Outlook 2003 reference is required.
Public Function SaveAsMSG(ByVal emlPath As String) As String On Error GoTo Err_SaveAsMSG
Dim sMsgName As String
Dim objPost As Outlook.PostItem Dim objSafePost As Redemption.SafePostItem Dim objNS & nbsp; As Outlook.NameSpace Dim objMAPIFolder As Outlook.MAPIFolder
Set objNS = Outlook.GetNamespace("MAPI") Set objMAPIFolder = objNS.GetDefaultFolder(olFolderInbox) Set objPost = objMAPIFolder.Items.Add(OlItemType.olPostItem)
Set objSafePost = New Redemption.SafePostItem
objPost.Save objSafePost.Item = objPost objSafePost.Import emlPath, Redemption.RedemptionSaveAsType.olRFC822 objSafePost.MessageClass = "IPM.Note" Rem: Remove IPM.Post Icon. objSafePost.Fields(PR_ICON_INDEX) = Empty sMsgName = "C:\TempMsg.msg"
objSafePost.SaveAs sMsgName, Outlook.OlSaveAsType.olMSG
SaveAsMSG = sMsgName
Rem: Move the item to the Deleted folder. objPost.DELETE
Rem: Delete the item from Deleted folder too. Set objMAPIFolder = objNS.GetDefaultFolder(olFolderDeletedItems) If objMAPIFolder.Items.Count > 0 Then objMAPIFolder.Items(objMAPIFolder.Items.Count).DELETE End If
Set objPost = Nothing Set objSafePost = Nothing Set objMAPIFolder = Nothing Set objNS = Nothing
Exit Function
Err_SaveAsMSG: SaveAsMSG = "" End Function
Edited by sivasakthi on 09 August 2006 at 2:20am
__________________
Thanks in advance,
Kannan.
|