Free lunch-programming text messages and emails using Google Calendar APIs

Source: Internet
Author: User

Google Calendar is an excellent calendar management tool that allows you to easily organize and share various calendars. Google also provides intimate and free text message and email reminders.

In addition, Google made public its API so that we can access it through programming in various languages.

API document for. Net: http://code.google.com/apis/calendar/docs/2.0/developers_guide_dotnet.html

Open source Class Library: http://code.google.com/p/google-gdata/

Below we will use this library and Google Calendar's free text message and email reminder functions to achieveProgramControl alert.

Preparations

First, you have to have a Google account, enable the Calendar function, and then configure the SMS function in the settings:

Then, configure the calendar you want to use and set the notification methods supported by default. (You can create or import multiple calendars under a calendar account. Each calendar reminder policy must be configured separately ):

In this case, OK.

PassCodeAdd activities and send short messages and email reminders

First, follow the instructions in this tutorial to install the class library, and then introduce the related DLL in the project:

Google. gdata. accesscontrol. dll

Google. gdata. Extensions. dll

Google. gdata. Client. dll

Google. gdata. Calendar. dll

Then write the code:

StringCalendaruri= Http://www.google.com/calendar/feeds/default/allcalendars/full";

StringUsername= Abcdef@gmail.com";

StringPassword= "123321";

//Create calendar service objects

CalendarserviceService= New Calendarservice("Calendartestapp");

//Set user name and password

Service.Setusercredentials (username, password );

//Find the account named"Test"Calendar

VaRQuery= New Calendarquery(Calendaruri );

CalendarentryC= Null;

Foreach(CalendarentryFInService.Query).Entries)

{

If(F.Title.Text= "Test") C=F;

}

//Build new activities

VaR Q= New Evententry(" Test Activity title " ," Test activity description \ N Test \ N Test " ," Beijing Chaoyang district central television headquarters building underpants left pants " );

Q.Times.Add (New When(Datetime.Now.Addminutes (8),Datetime.Now.Adddays (3)));

//Set the advance reminder time and method

Q.Reminder= New Reminder{Minutes= 7, Method= Reminder.Remindermethod.All };

//Add this activity to the calendar

Service.Insert (New Uri(C.Content.Absoluteuri), Q );

Run this code to add an activity with all the reminders to a calendar named "test". You will receive a short message or email notification within one minute.

In addition, I also encapsulated a helper class to simplify the overall operation process. The sending process is as follows:

Yes, I use the holy Chinese to write code again.ArticleProvide itsSource codeAnd DLL download, the class is very simple, if you do not like Chinese, you can modify the name.

Note that the 1.2-minute advance reminder time will still be considered as 1 minute after submission, because this parameter does not support units below minutes.

Activities created and the effect of sending notifications

After the task is executed, view the calendar and add the activity:

After 1 minute, let's take a look at the reminder we received. This is a text message reminder:

The text message reminder contains only the title and location information attributes.

 

This is an email reminder:

 

Think about what this can do?

New Mail Text Message notification: some professional mailboxes have the new mail text message reminder function, so we only need to regularly check the mailbox through the program, and then submit the new mail information using this method, you can implement the free SMS reminder function. (Note that you only set SMS reminders when setting reminders. Do not set email reminders, So Google will get you into an endless loop ~)

Weather forecast notification: The weather bureau is not afraid to see the cloud to change the port, and pay attention to real-time weather trends at any time, better than the daily fixed weather forecast text message service.

Notification of important website conditions: the website administrator wants to receive an email notification when an important website event or exception occurs. However, an SMS notification can be added, in this way, you can know the status of your website in near real time. In addition, Google's calendar also supports sharing. If there are multiple administrators, you can share this server's calendar with the sharing function. When there is an emergency, all administrators will receive text messages and email notifications! It's amazing. (Do not blow up the Mobile Server when it is under DDoS attacks ~ Google SMS account deficit ~)

RSS update notification: this function will be well received by the RSS reader.

Computer Operation Monitoring notification: No one secretly opens my computer when I am not in the office? Just get a program that runs automatically and send a notification when it starts up. You can write down all the programs he opens and any files he reads.

Notification of market trend changes: You can monitor the quote information of certain vulnerable commodities through the program, and send a notification when the changes occur. Stocks, foreign currencies, and gold are also applicable. "Wroning! Carrots fell! ."

Team Message notification: The software inputs and sends messages, and then sends a group of text messages to the team through the calendar sharing function, saving money :)

Game plug-in notification: "You have been trampled to death by a group of leaders !" "GM is watching you !" "Disconnected from the server !"

Twitter speech notification: Use a program to follow your target mm Twitter. When she speaks, you will receive a text message and then reply to her immediately. The feeling continues to be ++. (Before use, please confirm that the target will not be used in the wild when you are excited)

There are so many good ideas I have come up.

But do not misuse the service provided by Google. It doesn't matter if you are banned, and it will affect the normal use of others.

 

Download source code:

 

Download the XPS version of this article:

source code shunting: http://www.uushare.com/user/icesee/file/1822466

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.