Hi,
I am trying to retrieve the attachment of an email which is a zip file from my custom workflow. I would like to read the contents of the zip file and relate all the files back to the same email activity after unzipping. Please look into my below code and can someone guide me to proceed further. Many thanks for your help ...
// Retrieve all attachments associated with the email activity.
QueryExpression _attachmentQuery = new QueryExpression
{
EntityName = ActivityMimeAttachment.EntityLogicalName,
ColumnSet = new ColumnSet(true),
Criteria = new FilterExpression
{
Conditions =
{
new ConditionExpression
{
AttributeName = "objectid",
Operator = ConditionOperator.Equal,
Values = {_emailId}
},
new ConditionExpression
{
AttributeName = "objecttypecode",
Operator = ConditionOperator.Equal,
Values = {Email.EntityLogicalName}
}
}
}
};
EntityCollection results = _serviceProxy.RetrieveMultiple(
_attachmentQuery);
foreach (ActivityMimeAttachment a in ec.Entities)
{
string strcontent = a.body;
Can someone guide me how I unzip from here...
string zipPath = @"c:\example\start.zip";
string extractPath = @"c:\example\extract";
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
if (entry.FullName.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))
{
entry.ExtractToFile(Path.Combine(extractPath, entry.FullName));
}
}
}
I tried with the above code using console app but I like to use .net 4.0 framework.How to unzip and attach to the same email.Please guide me.






