Monday, December 29, 2008

Importing Contacts from Hotmail, Gmail, Yahoo using C#

Many of the social bookmark services offer a means to import/invite people from your online email accounts... This is a great feature.... Honestly, I was a bit afraid of it at first. However, I do see the usefulness of it.

I have found some help (C#) to do this... I do have some websites that this would help with... particularly those with marketing, contact lists, and newsletter features. It can be rather useful..

Yahoo class:

Google documentation:

Live/Hotmail documentation:

I will update this with any insights as I find it... and try it out.

Where to use it:

Lets say you have a "newsletter" or "prospect management" or "social" web-software. You can use such tools to import new contacts or friends and jump-start your system with your current business/family contacts.

Friday, December 19, 2008

Linking MS Access to SQL Server - labels

I had a label generator plugin for MS Word... from Avery Denison to print my labels. The data for the names/addresses resides in a SQL Server Database.

Avery Dennison can import from a Word doc, a Spreadsheet, or from an Access db.

I didnt want to download a spreadsheet all the time before importing, so I decided to use Access as a front end and link tables.... Theoretically it was a simple process..

Here is the article I found to do this:

It worked fine - until I closed the file and tried to re-open. Then I had to enter the password again.

Unfortunately, I had problems holding on the the username/password in the ODBC connection I made.... The following article explains why... The odbc connection to Sql Server connection kept defaulting to being a "trusted" connection instead of using the Sql Server username/password that I gave it. Thank you Bill Gates!

I tried applying the latest patch - no luck. Later I will revisit this...


I just saw I knew MS Word had some sort of feature like this - just couldnt figure out where. But like a fool, I tried using Avery Dennisons software.

No luck. I had problems connecting to SQL Server 2005 db. Probably the same problem as above. I am connected to it easily from my web server. Only my desktop has issues.


Ok.... Another angle:

- building MS Word on web server using C# and then downloading.

Looks like it may be possible to do what I want directly from the web server. I may need some sort of office components installed.. not sure.


Another angle. I am going to try to get MS Access to pull data from my database.
Then I will use MS Access to run the label writers...

YES!! This works if you have the data in MS Access. I was able to print the labels successfully! I even got MS Access to import the data from Excel. I just had to remove all the formatting done by my Excel generation code.

NEXT STEP: use vba to pull data into MS Access from my prospect management system. That would be very useful... if I had a canned tool to build mailing labels. I will need a way to pull the data from a web service or similar... I have some ideas that should work perfectly. Only constraint will be that the user has MS Access. Using data from:

Tuesday, December 16, 2008

System.Net.Mail.SmtpClient with login credentials (ASP.Net)

How to set login credentials for email ... C#...

Normally when I set up a SMTP form for a client using ASP.Net I do something like the following:

System.Net.Mail.MailMessage myMail = new System.Net.Mail.MailMessage();
myMail.From = "";
myMail.Subject = "subject of email";
myMail.To.Add(new MailAddress(""));
myMail.Body="This is the body of the email...";

System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("myserver",25);

I havent had to change that process until today. Now I needed to find ways to do "credentialed" email, since his web host required it. I didn't want to purchase/install any special active X object to do this.

However, there are some new tricks with 2.0 to handle this. Its something I didnt have to use til today.

You can put some settings in the Web.config file to handle smtp when you do a .Send() call

Or you can do code-behind method to do this...

Both seem to work well, depending on your preferences.


I have noticed lately that some email servers (like hotmail) gives warning messages when I do un-credentialed emails... The email says "This message has been blocked for your safety." next to it... and "This message may be a phishing scam" or "This message may be dangerous". Not good. When use the email credentials I think it checks the IMX records - and sees what server the email should come from.

This is the link hotmail gives it.. about Microsoft's "Sender ID" checking.

Sunday, December 14, 2008

RSS feeds... images and html

I was building a RSS feed for a client... They have an MLM-tool site promoting some health enhancing products like Max GXL (made by Max International) for Max International associates.

This site helps the different MLM associates to gain leads... (By the way - if you have a MLM business and need some tools for your team to build their downline, send me an email.. I am happy to build one for you too. )

I had trouble with the image tags... They didnt like to display in the RSS feed. I knew that it was possible.. Yahoo did it. Anyone else having trouble with putting images or other html inside RSS feeds? View the source and see how it is done.

Look at this... (my model)
Finally I got: to show the images properly.

It didn't take too long to figure out the trick... the opening tags... needed to use the html hex... (ampersand + #60 + semicolon) instead of the opening tag <. The closing tag is normal.. Just view source on the membersrss.aspx - that one has simpler html .

Friday, December 12, 2008

How to Turn off Autocomplete in html textbox

Every once in a while you have a form where you dont want Google's Autocomplete to try to guess at the text. For example, my wife runs a shipping business. I had a textfield for the tracking number. Each time she tried to enter it, it gave a long dropdown of the other tracking numbers.... But this is only an annoyance and not helpful.

Others may have credit card textfields... and need the same feature for shared computers - for obvious reasons. If someone else uses the computer, you dont want them to see the auto-complete of your credit card transaction.

This simple fix was courtesy of the following site:

Most sites just suggested turning off the google toolbar or explained that there was no fix.... But all things come to those who are persistant in finding the truth.

Social Bookmarking: Twitter This Button

Social bookmarking (like and are the latest craze..

I normally put in wigits on my blogs/websites to allow people to talk about sites/vote on page..

Recently, I put together my own Twitter button... Feel free to use it. I found it rather useful when putting on dynamic article pages.. or on blog posts.

Thursday, December 11, 2008

Not enough permissions. Inherit your page class from RadAjaxPage

I have been scratching my head for a few hours trying to figure out how to fix the following bug:
Finally - i figured it out ....

If you are trying out Telerik controls for the first time - you may get this. Or if your web host changes some of their configurations (which happened to me) you may also get this.


Server Error in '/' Application.
Not enough permissions. Inherit your page class from RadAjaxPage if you are running under Medium trust level.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Not enough permissions.Inherit your page class from RadAjaxPage if you are running under Medium trust level.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[InvalidOperationException: Not enough permissions.
Inherit your page class from RadAjaxPage if you are running under Medium trust level.]
Telerik.Web.UI.RadAjaxControl.AttachOnRender() +274


The fix is an obvious one. If you are reading this post, you probably did a search for this particular error. Once I figured it out - I felt pretty stupid, and I am a very experienced .Net programmer. I had made a database change (a small one) and then this error started happening... I couldnt figure out how my database change could have caused it.

My database change was not the culpret. The web host changing their trust/configuration settings was the problem.

To fix - I had to "read" the error.


VB.Net fix.....

Imports Telerik.Web.UI ' put at top of page

Partial Class MyShippingAccount
Inherits RadAjaxPage ' System.Web.UI.Page

C# fix....

using Telerik.Web.UI; // put at top of page

public partial class admin_ShipThis_modal : Telerik.Web.UI.RadAjaxPage //System.Web.UI.Page

No code-behind page? No problem...

<[percent-sign] @ Page Language="VB" Inherits="Telerik.Web.UI.RadAjaxPage" [percent-sign]>
<[percent-sign]@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" [percent-sign]>

Let me know it this helps.. I kept wondering if I broke something the whole time with my database change... and if Ajax components were complaining over it. But no. If you got this error - it is probably not your fault... and the fix is easy. I hope this saves you some head-scratching time.