Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I am a German - please don't wonder about my english.
I have code from this project site. Its a project "Mail Monitor".
So, i have it in VB 2008 - it work correct.

Only the Mail-Attachment will not displayed. I get the output "<System.__ComObject>

So,i think that i have a misstake in the outputcode

VB
If MobjIt(Me.Maillist.SelectedIndex + 1).Attachments.Count > 0 Then
                ' es wird auf Anhänge geprüft
                Form2.Text5.Text = ""
                For zaehler = 1 To MobjIt(Me.Maillist.SelectedIndex + 1).Attachments.Count
                    Form2.Text5.Text = ((Form2.Text5.Text & "<").ToString + (MobjIt(Me.Maillist.SelectedIndex + 1).Attachments.Item(zaehler).ToString + ">")).ToString
                    ' die Namen der Anhänge werden
                    ' eingefügt
                Next zaehler
            Else
                Form2.Text5.Text = "Keine Anhänge"
                ' keine Anhänge da
            End If

MobjIt is like this
Dim MobjIt As Microsoft.Office.Interop.Outlook.Items


How is the correct code for output the attachement in
line "Form2.Text5.Text = ((Form2.Text5.Text & "<").ToString + (MobjIt(Me.Maillist.SelectedIndex + 1).Attachments.Item(zaehler).ToString + ">")).ToString"

Many Thanks
Tom
Posted
Updated 20-Mar-10 5:23am
v2

1 solution

You have some problems with ToString().

1.
there are way too many ToString() calls everywhere, especially in the line at hand. Calling ToString() on something that already is a string, doesn't achieve anything.

2.
calling ToString() on a variable of some type T by default returns a string describing that type T; that is what is happening to your attachments. The solution is to use the proper methods and/or properties of that type, not ToString().

3.
System.Web.Mail.MailMessage is obsolete.
MSDN says you should look at System.Net.Mail classes.

:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900