Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 5th, 2007, 06:08 AM
Authorized User
 
Join Date: Feb 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default help, converting vb.net few lines to C#

 Could anybody please, help in converting the following few lines to C#???

  Public Sub Send_Email2(ByVal claimID As Integer, ByVal ApartmentID As Integer, ByVal strComplaintTitle As String, ByVal strFullName As String, ByVal strPriority As String, ByVal strProblemDetails As String)

            Dim UNMtxt As String = "[email protected]"

            Try

                Dim varMailbody As String
                varMailbody = "<b>Dear Admin,</b><br><br>"
                varMailbody = varMailbody & "You got a new ticket."
                varMailbody = varMailbody & "<b>Ticket Number: </b>" & claimID & "<b> Customer Name: </b>" & strFullName & "<br>"
                varMailbody = varMailbody & "<br><b>Problem Title: </b>" & strComplaintTitle & "<b> Priority: " & strPriority & "</b><br>"
                varMailbody = varMailbody & "<br><b>Problem Details: </b>" & strProblemDetails & "<br><br>Please check and reply.<br><br>Thank you<br>albab.com<br>"



                Dim ToAddress As String = UNMtxt

                Dim fromAddress As String = "[email protected]"

                '(1) Create the MailMessage instance
                Dim mm As New MailMessage(fromAddress, ToAddress)

                '(1.2) set the e-mail Priority
                mm.Priority = CInt(DropDownList1.SelectedValue)

                '(2) Assign the MailMessage's properties
                mm.Subject = "New Ticket - albab.com"
                mm.Body = varMailbody
                mm.IsBodyHtml = True
                '(3) Create the SmtpClient object
                Dim smtp As New SmtpClient
                'smtp.Host = "mail.albab.com"
                smtp.Host = "LOCALHOST"
                smtp.Port = 25

                smtp.Credentials = New NetworkCredential("[email protected]", "Sys!234")

                '(4) Send the MailMessage (will use the Web.config settings)
                smtp.Send(mm)

               Response.redirect("~/OrderCompleted.aspx");

                findlastTicketno()



            Catch ex As Exception
                Errlbl.Text = "Sorry! Your ticket can not be submitted at the moment!"
                Errlbl.Text = Errlbl.Text & " " & ex.Message

            End Try

        End Sub

 
Old March 5th, 2007, 07:28 PM
Authorized User
 
Join Date: Feb 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The following was obtained with Instant C#:

        public void Send_Email2(int claimID, int ApartmentID, string strComplaintTitle, string strFullName, string strPriority, string strProblemDetails)
        {

            string UNMtxt = "[email protected]";

            try
            {

                string varMailbody = null;
                varMailbody = "<b>Dear Admin,</b><br><br>";
                varMailbody = varMailbody + "You got a new ticket.";
                varMailbody = varMailbody + "<b>Ticket Number: </b>" + claimID + "<b> Customer Name: </b>" + strFullName + "<br>";
                varMailbody = varMailbody + "<br><b>Problem Title: </b>" + strComplaintTitle + "<b> Priority: " + strPriority + "</b><br>";
                varMailbody = varMailbody + "<br><b>Problem Details: </b>" + strProblemDetails + "<br><br>Please check and reply.<br><br>Thank you<br>albab.com<br>";



                string ToAddress = UNMtxt;

                string fromAddress = "[email protected]";

                //(1) Create the MailMessage instance
                MailMessage mm = new MailMessage(fromAddress, ToAddress);

                //(1.2) set the e-mail Priority
                mm.Priority = System.Convert.ToInt32(DropDownList1.SelectedValue );

                //(2) Assign the MailMessage's properties
                mm.Subject = "New Ticket - albab.com";
                mm.Body = varMailbody;
                mm.IsBodyHtml = true;
                //(3) Create the SmtpClient object
                SmtpClient smtp = new SmtpClient();
                //smtp.Host = "mail.albab.com"
                smtp.Host = "LOCALHOST";
                smtp.Port = 25;

                smtp.Credentials = new NetworkCredential("[email protected]", "Sys!234");

                //(4) Send the MailMessage (will use the Web.config settings)
                smtp.Send(mm);

               Response.redirect("~/OrderCompleted.aspx");

                findlastTicketno();



            }
            catch (Exception ex)
            {
                Errlbl.Text = "Sorry! Your ticket can not be submitted at the moment!";
                Errlbl.Text = Errlbl.Text + " " + ex.Message;

            }

        }


 
Old March 6th, 2007, 02:52 AM
Authorized User
 
Join Date: Feb 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much, that was a great help, you saved me.

Please note that void is underlined because of
"Invalid token void in calss, struct, order interface member declaration "
so what am i supposed to do??

 
Old March 6th, 2007, 10:43 AM
Authorized User
 
Join Date: Feb 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The method must be within a class or struct.







Similar Threads
Thread Thread Starter Forum Replies Last Post
help, converting vb.net few lines to C# nesrine ASP.NET 2.0 Professional 1 March 5th, 2007 07:10 AM
Datagrid scroll count (Lines) VB.NET 2003 peterasimpson VB.NET 4 November 24th, 2005 05:34 PM
Datagrid scroll count (Lines) VB.NET 2003 peterasimpson VB How-To 1 November 24th, 2005 12:33 AM
converting DTS package from VB 6 to VB .NET petroleo Pro VB Databases 0 August 18th, 2003 05:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.