【问题标题】:Convert VB to C#: Email sending routine将 VB 转换为 C#:电子邮件发送例程
【发布时间】:2010-12-31 05:57:00
【问题描述】:

我是 C# 新手,并且有一个用于发送电子邮件的 VB 子例程。

我不知道如何转换为 C#,有人可以帮我吗?

这是子:

Sub SendAdditionalEmails()
    Dim strDelimeter As String = ","
    Dim strEmailResult As String = ""
    'make sure they dont put a comma on the end (To)
    If InStr(Len(txtTo.Text) - 1, txtTo.Text, ",") > 0 Then
        txtTo.Text = Mid(txtTo.Text, 1, Len(txtTo.Text) - 1)
    End If

    'put the emails into the array
    Dim splitout As Array = Split(txtTo.Text, strDelimeter)
    Dim i As Integer = 0
    Me.pnlError.Visible = False
    For i = 0 To UBound(splitout)
        'loop through all the emails and send them ...
        '-------------------------------------------------------------------
        If SendEmail(splitout(i), txtSubject.Text, txtMessage.Text) = True Then
            txtTo.Text = ""
            txtSubject.Text = ""
            txtMessage.Text = ""
            chkTenantBrochure.Checked = False
            lblSuccess.Text = lblSuccess.Text & "An email was sent to: " & splitout(i) & "<br>"
            lblSuccess.Visible = True
        Else
            Me.pnlError.Visible = True
            lblError.Text = lblError.Text & "An email did not get sent to: " & splitout(i) & "<br>"
            lblError.Visible = True
        End If

    Next
End Sub

【问题讨论】:

    标签: c# .net vb.net code-conversion


    【解决方案1】:

    您可以借此机会增加您对 c# 和 vb.net 的了解并自行转换。

    【讨论】:

    • 感谢 a$$,我自己转换了它。不像我最初想的那么吓人:)
    【解决方案2】:

    Telerik 有一个非常方便的 web interface 用于将 VB.Net 转换为 C#。

    【讨论】:

    【解决方案3】:

    我建议你看看这个问题:

    Good way to convert VB.NET to C#?

    【讨论】:

      【解决方案4】:

      您可以使用Redgate's .NET Reflector 将已编译的 VB.NET 代码反汇编为 C#。

      【讨论】:

        猜你喜欢
        • 2011-11-11
        • 1970-01-01
        • 1970-01-01
        • 2012-09-16
        • 1970-01-01
        • 1970-01-01
        • 2016-02-14
        • 1970-01-01
        • 2016-04-17
        相关资源
        最近更新 更多