Outlook Attachment lost when sent from VB.net app...

I'm using the following code to send an email and pdf attachment.  The email goes out just fine and the attachment is there when I send to people on the Exchange server, but when I send to outside email addresses, the attachment is gone. (Email arrives OK though)

Any help would be appreciated.  I got this code from http://support.microsoft.com/?kbid=313803

Module Module1

    Sub Main()
        ' Create an Outlook application.
        Dim oApp As Outlook._Application
        oApp = New Outlook.Application()

        ' Create a new MailItem.
        Dim oMsg As Outlook._MailItem
        oMsg = oApp.CreateItem(Outlook.OlItemType.olMailItem)
        oMsg.Subject = "Send Attachment Using OOM in Visual Basic .NET"
        oMsg.Body = "Hello World" & vbCr & vbCr

        ' TODO: Replace with a valid e-mail address.
        oMsg.To = "user@example.com"

        ' Add an attachment
        ' TODO: Replace with a valid attachment path.
        Dim sSource As String = "C:\Temp\Hello.pdf"
        ' TODO: Replace with attachment name
        Dim sDisplayName As String = "Hello.pdf"

        Dim sBodyLen As String = oMsg.Body.Length
        Dim oAttachs As Outlook.Attachments = oMsg.Attachments
        Dim oAttach As Outlook.Attachment
        oAttach = oAttachs.Add(sSource, , sBodyLen + 1, sDisplayName)

        ' Send

        ' Clean up
        oApp = Nothing
        oMsg = Nothing
        oAttach = Nothing
        oAttachs = Nothing
    End Sub

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

Try sending it to two recipients, one inside and one outside. If the inside recipient gets the attachment and the outside doesn't it would almost point to your Exchange server deleting the attachment. Can you have your network admin follow the e-mail and see it there is a rule in the Exchange server that is deleting it before sending out? Another explanation could be the outside recipient's email server is doing the deletion. Did you try recipients with different email engines to see?
jallen_gomedicoAuthor Commented:

Thanks for the response.  Used all your suggestions and still kept pointing back to the Exchange Server.  Worked with our Network guy and still couldn't get it to stop stripping the attachment.  Found no rule that would cause this.  Same code in vb 6 works fine.  Which is frustrating.  Tried different recipients and ruled out that it was on the receivers end.

Ended up changing from Outlook to System.Net.Mail and using the following code which routes the mail away from our Exchange Server:
Imports System.Net.Mail
Sub Main()
        'Sub CreateMail_With_Attachment()

        Dim oMailMsg As New MailMessage

        Dim oMailClient As SmtpClient

        oMailMsg.From = New MailAddress("XXXX@YYYYY.com")

        oMailMsg.To.Add(New MailAddress("Receiver1@Outside.com"))
        oMailMsg.CC.Add(New MailAddress("Receiver2@Inside.com"))

        oMailMsg.Body = "Attached Sample Document for processing."

        oMailMsg.Subject = Sample Mail"

         oMailMsg.Attachments.Add(New Attachment("\\Server\Path\Sample.pdf"))

        oMailClient = New SmtpClient("Example.Provider.com")


     End Sub

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
Alan HardistyCo-OwnerCommented:
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
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.