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 ...

        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

Open in new window


MTIA

DWE
LVL 1
dwe0608Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

it's portuguese
Se não for uma imagem nem válida. Retorna direto false

If it is not an image or a valid one. Returns false

Anexos que não são embedded são obrigatóriamente olByValue, porém os embedded podem ser de qualquer tipo
Attachments that are not embedded must be olByValue, however embedded ones can be of any type

Busca a propriedade contentID do anexo. Anexos embedded não precisam necessáriamente gerar um ContentID. Anexos fixos não geram ContentID
Search for the contentID property of the attachment. Embedded attachments do not necessarily have to generate a ContentID. Fixed attachments do not generate ContentID

Busca a propriedade contentLocation. Para que o anexo seja embedded é necessario que essa propriedade esteja vazia ou nulla
Search for the contentLocation property. For the attachment to be embedded it is necessary that this property be empty or null
Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dwe0608Author Commented:
Hi Rgonzo1971 - many thanks for the translation ... so you have any experience with the functionality? Is it a reliable function?
0
Rgonzo1971Commented:
Nope
0
dwe0608Author Commented:
Thanks for the Translation ...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.