Friday, May 4, 2012

Google Apps email : new account for alias domain

Well, here's the very short version of what I learned the other night: if you create an email / GMail account for your primary domain in Google Apps, it takes an hour or two for the same account to automatically work for your alias domain.

Now, the long version....I run all of my email for my kcwebprogrammers.com domain through Google Apps mail servers.  This is done by setting up a Google Apps account and then routing the mail DNS records to Google server specified in your Apps account.  I also have what Google Apps calls a domain alias.  This is another domain that is assigned to the same Google Apps account, but it shares mailboxes with the primary domain.  In other words, if you create a new account / mailbox for the primary domain, then that same account will work on the alias domain too.

So I created a new email / Gmail account for kcwebprogrammers.com, sent it a test email, and it worked.  Then I sent another test email to the same account at the alias domain name, and it failed.  I couldn't figure it out since the Apps help on alias domains clearly says
"By adding a domain alias, you give every user in your domain a second email address (with the alias after the @). For example, if your domain is solarmora.com and you add solarmora.net as a domain alias, every user@solarmora.com will also receive mail addressed to user@solarmora.net."


After looking through all my Google Apps settings, looking through settings on my domain registrar, and even my web host, I did find something else in Google's help files saying that a different kind of email alias could take up to an hour to activate.  So I waited and tried it again the next day and it worked!  I wasted an hour or so looking at settings and help files, but as my wife reminds me, at least I learned a few things.

asp.net SelectParameters: use variable from code

Today I was building a GridView and wanted to set the SelectParameters of the SqlDataSource to use a value that was being sent in the query string.  But then I realized that the value I needed was not being sent in the query string and I didn't want to change the calling page to send the parameter that I needed.  What I wanted to do was to run a query in Page_Load to get the value I needed, store it in a variable, and then assign that variable to some SelectParameter.  But I'd never set the value of a SelectParameter to a value stored in a variable.

When I did a search, I found this solution that uses a generic .  That looked promising, but I couldn't get it to work.  I figured I could copy my variable into a Session variable, and then use a , but that seemed like overkill to create a Session variable just for that page.

The solution ended up being pretty simple.  What I did was:

  •  create a TextBox control on the page
  • set the TextBox Text property to the value of my variable obtained from the query in Page_Load
  • use a ControlParameter for the SelectParameter of the data source and specify that TextBox control as the control from which to get the value
In my case, it turned out that I could keep the control visible on the page because it was useful information, but if that isn't option for you then you could just set the control's visibility to false.