NewsLetter

 protected void btn_Save_Click(object sender, EventArgs e)
        {

            Attachment atcmt = null;
       
            if (FileUpload1 != null)
            {
               
                atcmt = new Attachment(FileUpload1.PostedFile.InputStream , FileUpload1.FileName);
            }
            Thread thread = new Thread(() => Common.SendNewsletter(txt_To.Text.Split(',').ToList(), txt_Subject.Text, "message", atcmt));
            thread.Start();

            txt_To.Text = "";          
            txt_Subject.Text = "";
            lblMessage.Text = "Your Message Successfully Send.";
            lblMessage.Visible = true;
        }

   #region SendNewsletter
        public static void SendNewsletter(List<string> toAddresses, string subject, string messageBody, Attachment  attachments)
        {
            if (toAddresses == null || subject.Length == 0)
                return;

            string from = (null != ConfigurationManager.AppSettings["emailSenderId"])
               ? ConfigurationManager.AppSettings["emailSenderId"].ToString() : "";
            string smtpServer = (null != ConfigurationManager.AppSettings["smtpServer"])
               ? ConfigurationManager.AppSettings["smtpServer"].ToString() : "";
            int port = (null != ConfigurationManager.AppSettings["smtpPort"])
               ? Convert.ToInt32(ConfigurationManager.AppSettings["smtpPort"]) : 0;
            string userName = (null != ConfigurationManager.AppSettings["smtpUserName"])
               ? ConfigurationManager.AppSettings["smtpUserName"].ToString() : "";
            string password = (null != ConfigurationManager.AppSettings["smtpPassword"])
               ? ConfigurationManager.AppSettings["smtpPassword"].ToString() : "";

            try
            {
                MailMessage mail = new MailMessage();

                mail.From = new MailAddress(from);
                foreach (var item in toAddresses)
                {
                    mail.To.Add(item);
                }
              if (attachments != null )  mail.Attachments.Add(attachments);
                mail.Subject = subject;
                mail.Body = messageBody;
                mail.IsBodyHtml=true;
                SmtpClient SmtpServer = new SmtpClient(smtpServer);
                SmtpServer.Port = port;
                SmtpServer.Host = (null != ConfigurationManager.AppSettings["smtpHost"])
               ? ConfigurationManager.AppSettings["smtpHost"].ToString() : "";
                SmtpServer.UseDefaultCredentials = false;
                SmtpServer.Credentials = new System.Net.NetworkCredential(userName, password);
                SmtpServer.EnableSsl = true;
                SmtpServer.Send(mail);
            }
            catch (Exception ex)
            {
                //LogException("Common.cs", "SendMail", ex.Message);
            }

        }
        #endregion


Webconfig
 <appSettings>
 <add key="smtpHost" value="smtp.gmail.com" />
    <add key="smtpPort" value="587" />
   <add key="smtpUserName" value="sample.smtpmail@gmail.com" />
    <add key="smtpPassword" value="123" />
    <add key="emailSenderId" value="sample.smtpmail@gmail.com" />
    <add key="emailReceverId" value="sample.smtpmail@gmail.com" />
    <add key="smtpServer" value="sample.smtpmail@gmail.com" />
  </appSettings>

String Separation Join

 string Result = String.Join(",", Emails.Select(s => s.ToString()));

Two Type Linq Joining Query

 int RoleID = Convert.ToInt32(Role);
             var Email = (from contact in dc.tbl_Contact
                          join usr in dc.tbl_User on contact.ContactID equals usr.ContactID
                          join usrrole in dc.tbl_UserRole on usr.UserID equals usrrole.UserID
                          join role in dc.tbl_Role on usrrole.RoleID equals role.RoleID
                          where contact.IsDelete == false && role.RoleID == RoleID

                          select new
                          {
                              emailcollection = contact.EmailIDOne
                          });
           

OR


             var xx = from tbl_UserRole ur in (dc.tbl_Role.Where(r => r.RoleID == RoleID).FirstOrDefault().tbl_UserRole)
                      select new
                      {
                          email = ur.tbl_User.tbl_Contact.EmailIDOne
                      };

Visual Studio 2008, 2010, 2011, 2012 Keyboard Shortcuts Keys

General Shortcut Keys
Shortcut
Description
Ctrl-X or Shift-Delete or Ctrl-L
Cuts entire line or Cuts the currently selected item to the clipboard
Ctrl-Del
Delete next "word"
Ctrl-C or Ctrl-Insert
Copies the currently selected item to the clipboard
Ctrl-V or Shift-Insert
Pastes the item from the clipboard at the cursor location
Ctrl-Z or Alt-Backspace
Undo the previous editing action
Ctrl-Space
To see intelligence dialog
Ctrl-Y or Ctrl-Shift-Z
Redo the previous undo action
Ctrl-S
Saves the current selected file
Ctrl-Shift-S
Saves all files and projects
Ctrl-P
Displays the Print dialog
F7
Switches from the design view to the code view in the editor
Shift-F7
Switches from the code view to the design view in the editor
Shift-F8 or F8
Navigate to compile time errors
Alt-Shift-A
Add Existing Item(file) to selected project
Ctrl-Shift-A
Add New Item(file) to selected project
Shift-F9
Display the selected item quick output means contains value while debugging
F12
Moves the cursor to the selected method, variable, class definition.
Shift-F12
Finds the reference to the selected method, variable, class or the item under the cursor
Ctrl-}
Match curly braces, brackets or compiler directives
Ctrl-Shift-}
Select text between matched braces, brackets or compiler directives
Text manipulation
Shortcut
Description
Tab
Indents the currently selected line or lines by one tab stop. If there is no selection, this inserts a tab stop
Tab-Tab
Complete the syntax of an item. Example- Write for and now press Tab-Tab, then for loop syntax will be automatically completed. Similarly it works for property, index, class syntax.
Shift-Tab
Moves current line or selected lines one tab stop to the left
Backspace or Shift-Backspace
Deletes one character to the left of the cursor
Ctrl-K, Ctrl-C
Marks the current line or selected lines of code as a comment, using the correct comment syntax for the programming language
Ctrl-K, Ctrl-U
Removes the comment syntax from the current line or currently selected lines of code
Ctrl-K, Ctrl-D
Do proper alignment of all the code of design view and code view
Ctrl-T or Shift-Enter
Swaps the characters on either side of the cursor. (For example, AC|BD becomes AB|CD.) Available only in text editors
Ctrl-U
Changes the selected text to lowercase characters
Ctrl-Shift-U
Changes the selected text to uppercase characters
Ctrl-Shift-Right Arrow
Select the entire word with space from start to end
Ctrl-Right Arrow
Move the cursor in forward direction word by word
Shift-End
Select the entire line from start to end
Shift-Home
Select the entire line from end to start
Shift-Alt-Arrows or Alt-Mouse
Column wise text selection for text manipulation
Ctrl-Delete
Deletes the word to the right of the cursor
Ctrl-Backspace
Deletes the word to the left of the cursor
Ctrl-G
Jump to line number or go to line
Project related
Shortcut
Description
Ctrl-Shift-B
Builds the solution
Ctrl-N
Displays the New File dialog. Note: files created this way are not associated with a project. Use Ctrl-Shift-A to add a new file in a project
Ctrl-Shift-N
Displays the New Project dialog
Ctrl-O
Displays the Open File dialog
Ctrl-Shift-O
Displays the Open Project dialog
Ctrl-M-O
Collapse all the methods, classes, regions in the current code behind or class file
Ctrl-M-P or Ctrl-M-L
Expands all the methods, classes, regions in the current code behind or class file
Ctrl-F
Displays the Find dialog
Ctrl-H
Displays the Replace dialog
Ctrl-Shift-F
Find the reference of selected item into entire solution.
Ctrl-Tab
Move from one opened file to another opened file in visual studio.
F9
Sets or removes a breakpoint at the current line
Ctrl-F9
Enables or disables the breakpoint on the current line of code. The line must already have a breakpoint for this to work
F5
Runs the code with invoking the debugger.
Ctrl-F5
Runs the code without invoking the debugger.
F4 or Alt-Enter
Displays the Properties window, which lists the design-time properties and events for the currently selected item
Ctrl-Alt-S
Displays the Server Explorer window, which allows you to view and manipulate database servers, event logs, message queues, web services, and many other operating system services
Ctrl-Alt-L
Displays the Solution Explorer, which lists the projects and files in the current solution
Ctrl-Alt-X
Displays the Toolbox, which contains controls and other items that can be dragged into editor and designer windows
Ctrl-Alt-I
Displays the Immediate window, where you can find the controls or variables values or can do data manipulation during debugging

Search This Blog

Arsip Blog

Powered by Blogger.

Recent

Comment

Author Info

Like This Theme

Popular Posts

Video Of Day

jishnukanat@gmail.com

Sponsor

Most Popular