Tuesday, November 17, 2009

Configuring outlook for accessing Gmail

To configure Outlook 2007 for your Gmail address:

  1. Enable POP in your email account. Don't forget to click Save Changes when you're done.
  2. Open Outlook.
  3. Click the Tools menu, and select Account Settings...
  4. On the E-mail tab, click New...
  5. If you are prompted to Choose E-mail Service, select Microsoft Exchange, POP3, IMAP, or HTTP, and click Next.
  6. Fill in all necessary fields to include the following information:

    Your Name: Enter your name as you would like it to appear in the From: field of outgoing messages.
    Email Address: Enter your full Gmail email address (username@gmail.com). Google Apps users, enter your full address in the format username@your_domain.com.
    Password: Enter your email password.

    Manually configure server settings or additional server types: Leave this option unchecked if you want to automatically configure Outlook 2007. If you want to manually configure Outlook 2007, check this box now. Google Apps users should configure manually as follows.


  7. Click Next. If you are configuring Outlook 2007 automatically, you're done! Just click Finish.


  8. If you are configuring Outlook 2007 manually, select Internet E-mail and click Next.
  9. Verify your User Information, and enter the following additional information:

    Server Information

    Account Type: POP3

    Incoming mail server:
    pop.gmail.com (Google Apps users, enter the server names provided, don't add your domain name in these steps)

    Outgoing mail server (SMTP):
    smtp.gmail.com

    Logon Information

    User Name: Enter your Gmail username (including @gmail.com). Google Apps users, enter your full address in the format username@your_domain.com

    Password: Enter your email password.

    Require logon using Secure Password Authentication (SPA): Leave this option unchecked.


  10. Click the More Settings... button, and select the Outgoing Server tab.
  11. Check the box next to My outgoing server (SMTP) requires authentication and select Use same settings as my incoming mail server.


  12. Click the Advanced tab, and check the box next to This server requires an encrypted connection (SSL) under Incoming Server (POP3).
  13. In the Outgoing server (SMTP) box, enter 587, and select TLS from the drop-down menu next to Use the following type of encrypted connection:.


  14. Click OK.
  15. Click Test Account Settings... After receiving 'Congratulations! All tests completed successfully', click Close.
  16. Click Next, and then click Finish.

Congratulations! You're done configuring your client to send and retrieve Gmail messages.

Friday, November 13, 2009

Use Gmail IMAP in Microsoft Outlook 2007

We’ve all been hearing about the new IMAP support in Gmail, but how do we access that from Outlook? Those of you that have been waiting patiently will be happy to know all the instructions are on this page.
Using IMAP we can synchronize email across multiple devices, since the mail stays on the server. You already stopped reading this part and skipped down to the instructions, didn’t you?
Enable IMAP in Gmail Settings
Open your Settings panel in Gmail, and then click on the “Forwarding and POP/IMAP” tab.
image
Now click the Enable IMAP radio button, and click Save Changes.
image
Add Account to Outlook
Use the Tools menu you to open the Account Settings panel.
image
If this is your first account you’ll be prompted for the wizard, otherwise you’ll need to click the New button under the E-mail tab.
image
Now select the “Microsoft Exchange, POP3, IMAP or HTTP” option and hit next.
image
Select the checkbox for “Manually configure server settings” and everything on that page will gray out. Hit the next button again.
image
Now select “Internet E-mail”  (Didn’t we just do this? This wizard is taking too long…)
image
Finally we can enter some settings! Add in all your personal information here.
image
Note: If you are outside of the US you may need to use imap.googlemail.com and smtp.googlemail.com instead of imap.gmail.com and smtp.gmail.com.
Note: for Gmail Apps accounts, you’ll need to put in your full email address wherever you see an @gmail.com above. For instance, if your account was geek@howtogeek.com you would put that in the E-mail address field as well as the User Name field.
Click on the “More Settings” button and find the Outgoing Server tab, where you’ll need to check the box for “My outgoing server requires authentication”
image
Now choose the Advanced tab, and enter the following values (Very important)

  • Incoming Server: 993
  • Incoming Server encrypted connection: SSL
  • Outgoing Server: 587
  • Outgoing Server encrypted connection: TLS
image
Note: If you are having an issue with your sent email not showing up in Gmail, you can use the Folders tab, and then select the [Gmail] \ Sent Mail folder.
Note: Only do this step if your mail is not showing up, otherwise it will duplicate the sent mail.
image
Now that you’ve closed out that dialog, you can click the Test Account Settings button to make sure everything is going to work.
image
If all goes well, you should see a success message.
image
Note: Some ISPs restrict outgoing mail, so if you have a problem sending a test message you’ll need to consult with their documentation.
Accessing Your Mail
Now that everything is working you’ll notice a new set of folders for your Gmail account. (I’m using Gmail apps, which is why you don’t see an @gmail.com email address)
All of your labels will show up as separate folders, and the built-in “folders” in Gmail will be under the new [Gmail] folder.
 image
Outlook Flags = Gmail Stars
If you want to star a message in Gmail, you just need to flag it in Outlook. When I flagged this message from Mysticgeek…
image 
It shows up in Gmail as a starred message. (And it works the other way too)
image
Sending Email from Outlook
To send a new email from your Gmail account, just change the “Account” drop-down to your Gmail address before you send a message.
image
Note that if you only use Gmail, you won’t have this drop-down and it will default to your Gmail.
Final Thoughts
Here’s a few things to keep in mind:

  • Gmail Labels = Outlook Folders. To label a message, add it to a folder.
  • Gmail Stars = Outlook Flags.
  • Do Not move spam messages to the “Junk E-mail” folder in Outlook, move them to the [Gmail] \ Spam folder.
  • Outlook has a built-in Search Folder for “Large Mail”, which will let you easily find messages with large attachments.
Now that you can access your starred and labeled messages, you can start using Outlook’s excellent Search Folders to find messages more easily.



Raju Jetla

Tuesday, November 3, 2009

How To Map Output Parameter From Stored Procedure To LINQ


 In this article we will create one more SP but this will be returning one output parameter. We will map this SP to LIQ file and consume it using LIQ. So let’s crate one stored procedure which will take two parameters as input which is username and password of the user and if the user credentials matches, we will return one output parameter.


This output parameter will tell us weather user is authenticated or not. If he is authenticated we will redirect our users to links pages where he can see all the links that he has stored in his Favorite list. First of all let’s crate stored procedure in our database.  




SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER PROCEDURE fm_AuthenticateUser

     

      @Username varchar(150),

      @Password varchar(16), 

      @Uid int OUTPUT

AS

BEGIN

     

      SET NOCOUNT ON;  

      Declare @Pass varchar(16)

      Declare @id int

      SELECT @Pass = Password, @id = UserId

      FROM dbo.lnkUsers

      WHERE Username = @Username

     

      IF @Password <> @Pass

      BEGIN

            SET @Uid = 0

      END

      ELSE

      BEGIN

            SET @Uid = @id

      END

END

GO
As you see if the user credentials are not matching we will set the output parameter to zero. If they are matches we will return the user id of that user. On the basis of this return parameter we will redirect our user to appropriate page.


Once this is done go to your and map this stored procedure to your .net application similar way we did before. If you have not read previous articles please read them here.  As I mentioned this is a special case where the stored procedure is returning us some parameter which we need to handle in LIQ. Before we go ahead and handle that let’s first create a login page where user can enter his/her credentials. For now I will just add this stuff to my default page as that will be the start page of our application. Make your page look like as below.


Now let’s add this code into the click event of your login button.


protected void btnLogin_Click(object sender, EventArgs e)

    {

        LinkManagerDataContext lm = new LinkManagerDataContext();

        Nullable<int> userid = null;

        lm.fm_AuthenticateUser(txtUsername.Text.ToString(), txtPassword.Text.ToString(),ref userid);

        if (userid != 0)

        {

            Session["uid"] = userid;

            Response.Redirect("links.aspx");

        }

        else

        {

            lblREsult.Text = "Authentication Failed";

        }

    }
If you see here we defined our userid integer is because LIQ to SQL maps output parameters from SP as reference type (using ref keyword)



Once the user is authenticated we will store his userid into session and foreword him to the links page where we will retrieve the user’s favorite links using the userid we have in session.


For this write code below in the page load event of the links page.


protected void Page_Load(object sender, EventArgs e)

    {

        if (!IsPostBack)

        {

            if (Session["uid"] != null)

            {

                LinkManagerDataContext lm = new LinkManagerDataContext();

                var links = lm.fm_GetLinks(Convert.ToInt32(Session["uid"]));

                grdLinks.DataSource = links;

                grdLinks.DataBind();

            }

        }




    }




Go ahead and run the application. Once the credentials are matched you should see some thing like below.



NOTE:

 I have written a separate article on how to retrieve data using stored procedure accepting an input parameter before this one so the links page might have some extra controls and its code behind may have some extra code as well.

Watch the gray out area on the above screen shot.



So in this article we understood how we can handle the stored procedure’s output parameters using LIQ to SQL functionality in your application.


Thanks

Raju Jetla

Recent Comments