views:

100

answers:

4

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, 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
A: 

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

Aviad P.
+1  A: 

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

Good way to convert VB.NET to C#?

chakrit
There is, code-conversion
Aviad P.
@Aviad P. Thanks :)
chakrit
+1  A: 

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

JohnE
some of the code is VB specific and I do not want to use the visual basic namespace
Then this question should help you: http://stackoverflow.com/questions/1722896/vb-to-c-functions
Meta-Knight
+1  A: 

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

ElGringoGrande
Thanks for the kick in the a$$, i converted it my self. not as intimidating as i first thought :)