Home
TeamSite
Problem with importing emails using SaveEmailCmd
Goce
Hi,
I am trying to import emails into a worksite folder using the SaveEmailCmd from IManExtLib. I am using the following C# code below to do it. However i get a problem with the profile dialog displaying when i execute the save. All the mandatory fields are filled and all the user has to do is press save. I want the email to be saved automatically into the specified worksite folder with no dialogs displayed and therefore no user interaction. This problem is driving me insane can anybody please help!!!.
The code i am using is below;
////////////////////////////////////////////////////////////////////////////
IManFolder fldID = (IManFolder)dms.GetObjectBySID(workFolderID);
SaveEmailCmd cmd = new SaveEmailCmdClass();
ContextItems context = new ContextItemsClass();
imCheckinOptions eKeepCheckedout = imCheckinOptions.imDontKeepCheckedOut;
context.Add("NRTDMS", dms);
context.Add("IManExt.SaveEmailCmd.EmailMsgFile", filename);
context.Add("DestinationObject", fldID);
cmd.Initialize(context);
cmd.Update();
try
{
cmd.Execute();
}
catch (Exception exc)
{
Logger.append("Unable to import Email: " + fi.FullName);
Logger.append(exc.Message);
}
///////////////////////////////////////////////////////////////
Find more posts tagged with
Comments
jny
There isn't a way to use the SaveEmailCmd silently. Here's VB code example of how to use it (in UI mode):
Option Explicit
Private Sub Form_Load()
Dim dms As New ManDMS
Dim sess As IManSession
Dim db As IManDatabase
Dim fldrs As IManFolders
Dim fldr As IManFolder
Dim params As IManFolderSearchParameters
Dim dblist As New ManStrings
Dim doc As IManDocument
Dim fldrdox As IManDocuments
Dim cmd As SaveEmailCmd
Dim context As ContextItems
Dim sImportpath As String
Dim lCount As Long
Dim i As Long
Dim bRefresh, varDox, ierrs
sImportpath = "C:\Temp\DiSC Assessment.msg"
Set sess = dms.Sessions.Add("DSS_WIN2003SERV")
sess.TrustedLogin
'Get NRTDMS
Dim nDMS As NRTDMS
Set nDMS = dms
Set db = sess.Databases.ItemByName("WS8DSS1")
dblist.Add db.Name
Set params = dms.CreateFolderSearchParameters
params.Add imFolderName, "EMAIL PROFILED"
'Search for folder by folder name
Set fldrs = sess.WorkArea.SearchFolders(dblist, params)
Set fldr = fldrs.ItemByIndex(1)
Dim nrtfldr As NRTFolder
Set nrtfldr = fldr
'String format representing the import destination.
Dim strPreSelectedLoc As String
strPreSelectedLoc = "\" & sess.ObjectID & "\" & db.ObjectID & "\My Folders\" & fldr.ObjectID
Set cmd = New IMANEXTLib.SaveEmailCmd
Set context = New IMANEXTLib.ContextItems
With context
.Add "IManExt2.DocOpenLocation", strPreSelectedLoc
.Add "IManExt.SaveEmailCmd.BrowseLocation", False
.Add "DestinationObject", nrtfldr 'it accepts only object type NRTFolder
.Add "ParentWindow", Me.hWnd
.Add "IManExt.SaveEmailCmd.EmailMsgFile", sImportpath
' Optional: you may use any of these date fields to populate the send/receive dates of the e-mail
' .Add "IManExt.Import.Custom21", CDate(Date)
' .Add "IManExt.Import.Custom22", CDate(Date)
' .Add "IManExt.Import.Custom23", CDate(Date)
' .Add "IManExt.Import.Custom24", CDate(Date)
End With
With cmd
.Initialize context
.Update
If .Status = (.Status And nrActiveCommand) Then
.Execute
On Error Resume Next
bRefresh = context("IManExt.Refresh")
If bRefresh Then ' Command executed successfully
End If
End If
End With
Set dms = Nothing
Set sess = Nothing
Set db = Nothing
Set fldrs = Nothing
Set fldr = Nothing
Set params = Nothing
Set dblist = Nothing
Set doc = Nothing
Set fldrdox = Nothing
Set cmd = Nothing
Set context = Nothing
End
End Sub
Jan999
Try ImportCmd instead. I've done it this way and it works just fine.