Hello,
i use this code to return the information from the received email:
SPListItem item = list.AddItem();
item[SPBuiltInFieldId.Title] = message.Subject;
item[MATQConstants.FIELD_MATQ_From] = message.From;
if (message.To.Count > 1)
item[MATQConstants.FIELD_MATQ_TO] = message.To.Aggregate((x, next) => x + ";" + next);
else
item[MATQConstants.FIELD_MATQ_TO] = message.To;
if (message.CC.Count > 1)
item[MATQConstants.FIELD_MATQ_CC] = message.CC.Aggregate((current, next) => current + ";" + next);
else
item[MATQConstants.FIELD_MATQ_CC] = message.CC;
item[MATQConstants.FIELD_MATQ_Body] = message.HtmlBody;
item[MATQConstants.FIELD_MATQ_Date] = message.Date;
item[MATQConstants.FIELD_MATQ_Status] = "0";
SaveImage(message, web);
if (exchangeMessageInfo.HasAttachments)
{
SPAttachmentCollection fileAttch = item.Attachments;
foreach (Attachment attachment in message.Attachments)
{
byte[] buffer = new byte[(int)attachment.ContentStream.Length];
attachment.ContentStream.Read(buffer, 0, (int)attachment.ContentStream.Length);
attachment.ContentStream.Close();
fileAttch.Add(GetValidFileName(attachment.Name), buffer);
}
}
item.Update();
but i have a problem:
if i have an email attached in my Email (Principal email), i cannot find this attached email in MailMessage.Attachments.
Help please.
Best regards
Nacata
<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>DE</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<w:DoNotOptimizeForBrowser/>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>
<![endif]–>