I’m trying to modify InteractionExtensionSample, to display email interaction ID after clicked on “Button” or it would be perfect id I can get subject, from, to and body directly from items in red border.
In the InteractionExtensionSample you have the Case in MySamplePresentationModel.cs, so you need to set that.
In the MySampleView.xaml.cs modify the Create method to look like this:
public void Create()
{
IDictionary<string, object> contextDictionary = Context as IDictionary<string, object>;
object caseView;
contextDictionary.TryGetValue("CaseView", out caseView);
object caseObject;
contextDictionary.TryGetValue("Case", out caseObject);
ICase @case = caseObject as ICase;
if (@case != null)
{
Model.Case = @case;
}
}
Then in your button press method you can get the Case and from the Case get the Interaction, check what type of interaction it is and then get the properties of that interaction.
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
//Model.ResetCounter();
IInteraction interaction = Model.Case.MainInteraction;
if(interaction is IInteractionInboundEmail)
{
IInteractionInboundEmail email = interaction as IInteractionInboundEmail;
string subject = email.EntrepriseEmailInteractionCurrent.Subject;
string from = email.EntrepriseEmailInteractionCurrent.From;
string to = "";
foreach(string s in email.EntrepriseEmailInteractionCurrent.To)
{
to += " " + s;
}
to = to.Trim();
string text = email.EntrepriseEmailInteractionCurrent.MessageText;
MessageBox.Show(email.InteractionId + " Subject: " + subject);
}
}
Now I have another problem, because I cannot find content of attachments. It looks that content is empty “null”. Is there any other option to save all attachments to disk?
Genesyslab.Desktop.Modules.Core.Model.Interactions.IInteraction interaction = Model.Case.MainInteraction;
if (interaction is IInteractionInboundEmail)
{
IInteractionInboundEmail email = interaction as IInteractionInboundEmail;
foreach (var attachment in email.EntrepriseEmailAttachments)
{
//Save to disk
}
The reason is that in some cases I need to export email to eml file which could be opened in Outlook/Thunderbird etc…
Could you give me some tips how to use IContactService? I cannot found it in API refference. Is there any document regarding Enterprise SDK 8.5 framework?