Tuesday, February 26, 2013

Send mail comman code


public static void Send(string[] To, String Subject, String Body,bool IsBodyHtml)
    {
        try
        {
            var smtp = new SmtpClient
            {
                Host = Host,
                EnableSsl = true,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(SMTPUser, Password),
            };

            var message = new MailMessage()
            {
                Subject = Subject,
                Body = Body
            };

            foreach (var vv in (from s in To select (new MailAddress(s))))
            {
                message.To.Add(vv);
            }
           
            message.From = new MailAddress(From);
            message.IsBodyHtml = IsBodyHtml;
            smtp.Send(message);
        }
        catch
        {
        }
    }

Wednesday, February 13, 2013

Remove item from array list of multiple column.


This problem occured when i was doing project in dotnetnuke 5.6.3 so in arraylist there have multiple columns and I and remove row which contains particular value of type.this is the code for solve this problem.

DotNetNuke.Entities.Users.UserController oUserController = new DotNetNuke.Entities.Users.UserController();
           
            ArrayList listroles = oUserController.GetUsers(this.PortalId, true, true);
            int j = 0;

            for (int i = 0; i < listroles.Count; i++)
            {
                DotNetNuke.Entities.Users.UserInfo info = (DotNetNuke.Entities.Users.UserInfo)listroles[i];
                if (info.Username == UserInfo.Username)
                {
                    listroles.Remove(info);
                }
            }