开发者

Convert VB to C#: Email sending routine

I am new to C# and have a VB sub routine for sending emails.

I am not sure how to convert to C#, can someone please help me?

here is the sub:

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, strDelime开发者_如何学Cter)
    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


You could take this opportunity to increase your knowledge of both c# and vb.net and convert it yourself.


Telerik has a pretty handy web interface for converting VB.Net into C#.


I'd suggest you take a look at this question:

Good way to convert VB.NET to C#?


You can use Redgate's .NET Reflector to disassemble your compiled VB.NET code into C#.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜