Correkt语法的语法 [英] How ist the correkt syntax

查看:74
本文介绍了Correkt语法的语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好
我是德国人-请不要怀疑我的英语.
我有此项目站点的代码.它是一个项目邮件监视器".
因此,我在VB 2008中拥有它-可以正常工作.

仅邮件附件不会显示.我得到输出< System .__ ComObject>

所以,我认为我在输出代码中有一个误区

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

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"


中输出附件的正确代码 非常感谢
Tom


Many Thanks
Tom

推荐答案

您在ToString()上遇到一些问题.

1.
到处都有太多ToString()调用,尤其是在当前行中.在已经是字符串的对象上调用ToString()并不会实现任何效果.

2.
默认情况下,对某个类型T的变量调用ToString()会返回描述该类型T的字符串;那就是你的附件正在发生的事情.解决方案是使用该类型的正确方法和/或属性,而不是ToString().

3.
System.Web.Mail.MailMessage已过时.
MSDN说您应该查看System.Net.Mail类.

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

:)


这篇关于Correkt语法的语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆