dwe0608
asked on
VB.NET - Embedded Attachment in Outlook email (Office365)
Hi Guys
using vb.net 2017 ...
The following piece of code has been converted from a C# snippet I located ... I don't speak Spanish and it seems the comments were originally made in that language ... so I have two queries, can someone convert the Spanish comments to English and secondly is the function going to work well ... I've added the Try Catch functionality and would like to improve upon that because I don't know if I am catching the correct errors ...
MTIA
DWE
using vb.net 2017 ...
The following piece of code has been converted from a C# snippet I located ... I don't speak Spanish and it seems the comments were originally made in that language ... so I have two queries, can someone convert the Spanish comments to English and secondly is the function going to work well ... I've added the Try Catch functionality and would like to improve upon that because I don't know if I am catching the correct errors ...
Public Function IsEmbeddedAttachment(attachment As Outlook.Attachment) As Boolean
'Se não for uma imagem nem válida. Retorna direto false
'if (!DocumentFormat.IsImageFormat(Path.GetExtension(attachment.FileName)))
' return false;
Try
'Anexos que não são embedded são obrigatóriamente olByValue, porém os embedded podem ser de qualquer tipo
If (attachment.Type <> Outlook.OlAttachmentType.olByValue) Then
Return True
End If
'Busca a propriedade contentID do anexo. Anexos embedded não precisam necessáriamente gerar um ContentID. Anexos fixos não geram ContentID
Dim strATTACH_CONTENT_ID As String = attachment.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E").ToString()
'Busca a propriedade contentLocation. Para que o anexo seja embedded é necessario que essa propriedade esteja vazia ou nulla
Dim strATTACH_CONTENT_LOCATION As String = attachment.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3713001E").ToString()
If (String.IsNullOrEmpty(strATTACH_CONTENT_ID)) Or (String.IsNullOrEmpty(strATTACH_CONTENT_LOCATION)) Then
Return True
End If
If (attachment.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x37050003") = 6) Then
Return True
End If
If (attachment.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x37140003") = 4) Then
Return True
End If
Catch ex As System.Runtime.InteropServices.COMException
' fall through
' and treat as an embedded attachment
Return True
End Try
Return False
End Function
MTIA
DWE
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Nope
ASKER
Thanks for the Translation ...
ASKER