Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Sending mail with a Netduino Plus


  • Please log in to reply
24 replies to this topic

#1 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 16 October 2011 - 07:53 PM

Hi :)

Today I didn't want to do a thing with electronics, just code a bit. So I did. I wrote a simple socket class (usable in both VB and C#) and extended the class with an SMTP class.

Now it's possible to send mails through an SMTP server. The class doesn't have authentication yet, but it works! :D

// By defining the CORRECT! date, mail messages could get a lower spam score in spam filters
//Utility.SetLocalTime(new DateTime(2011, 10, 16, 20, 43, 0, 0));

// Defines the sender
SMTP_Client.MailContact From = new SMTP_Client.MailContact("administrator@localhost", "Your name");
// Defines the receiver
SMTP_Client.MailContact Receiver = new SMTP_Client.MailContact("someone@else", "Recipients name");
// Defines the mail message
SMTP_Client.MailMessage Message = new SMTP_Client.MailMessage("Small test result");
Message.Body = "This mail is sent by a Netduino :-)\r\n";
Message.Body += "Good day!";

// Initializes the mail sender class
SMTP_Client Sender = new SMTP_Client("smtp.yourisp.com");

// Sends the mail
Sender.Send(Message, From, Receiver);

The code can be downloaded at http://netmftoolbox....ol/BrowseLatest
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 16 October 2011 - 10:56 PM

Hey, it just sent me an e-mail! :) Cool! Chris

#3 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 17 October 2011 - 04:21 AM

May we set in touch all our Netduinos, so that they begin to exchange mails each other? Maybe even fall in love?...Uhm...Chris, how may I check the gender of my board? Just kidding... Stefan? The mail+socket section is dedicated to the Pluses, I think. Wouldn't be better organize the Toolbox as several projects, instead a whole one? In that way, an user simply refers to the projects he needs, without copy-and-paste modules everywhere... Cheers
Biggest fault of Netduino? It runs by electricity.

#4 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 17 October 2011 - 05:14 AM

Uhm...Chris, how may I check the gender of my board?

According to the french l'ordinateur (the computer) is female. Lucky us :D

Stefan? The mail+socket section is dedicated to the Pluses, I think. Wouldn't be better organize the Toolbox as several projects, instead a whole one? In that way, an user simply refers to the projects he needs, without copy-and-paste modules everywhere...

Actually, they're seperated at the moment, but still in one repository. (Toolbox.NETMF.Hardware.dll & Toolbox.NETMF.NET.dll)
I was in doubt how to handle it, but since I also have a wifi solution on my desk, and the SimpleSocket-class might support that some day, it's all a bit connected.
I'm still unsure what's the best way to deal with it though. Perhaps I'll split it up eventually.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#5 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 17 October 2011 - 05:40 AM

So, "ordinateur" is female?...in Italian is male, except for the handheld calculator that (often, not always) is called "calcolatrice" (thus female). Ok, let's forget... Well, here is not the right place to discuss about the organization of the projects, but the available rooms in the Netduino are limited, especially on the Plus. My viewpoint is that an user should act as follows: - decide, then build the hardware blocks around Netduino; - creates his/her own custom project, referring the satellite projects tailored for the hardware used. In such a way, the satellite drivers should keep intact for anyone, with ease of sharing and maintenance. We should also estabilish some standard interface for similar drivers, that basically make the same things. Just random thoughts...better continue privately, if you want. Cheers
Biggest fault of Netduino? It runs by electricity.

#6 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 17 October 2011 - 05:57 AM

Just random thoughts...better continue privately, if you want.

You've got mail (not sent by a netduino) :D
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#7 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 17 October 2011 - 04:15 PM

In such a way, the satellite drivers should keep intact for anyone, with ease of sharing and maintenance.
We should also estabilish some standard interface for similar drivers, that basically make the same things.

I came to the same conclusion and I have a seperate project plus example on how to use any classes. I find it easier and lets face it, disc space is cheap.

Regards,
Mark

To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#8 Johan

Johan

    Member

  • Members
  • PipPip
  • 10 posts

Posted 01 November 2011 - 07:55 AM

Do you think it's possible to use Exchange Webservice Managed API with Netduino? I have made a program for my computer to add tasks to Exchange through the API. But it would be fun to log data to an Exchange server. Or schedule appointments, make tasks or send/receive email or write notes.

#9 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 01 November 2011 - 08:12 AM

Do you think it's possible to use Exchange Webservice Managed API with Netduino?

It probably can be made possible, but this class only supports SMTP.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#10 Johan

Johan

    Member

  • Members
  • PipPip
  • 10 posts

Posted 01 November 2011 - 08:36 AM

I'll try to look into the possibility to use the API. But I don't know yet where to start :-) When it comes to programming I'm still a newb, but I have to start somewhere :-) I'll make a project of it.

#11 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 01 November 2011 - 09:10 AM

I'll try to look into the possibility to use the API.
But I don't know yet where to start :-)
When it comes to programming I'm still a newb, but I have to start somewhere :-)
I'll make a project of it.

A bit offtopic in this thread, but the API, does it use web requests? There are several other projects that use http requests for their things :)
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#12 Dugley DoRight

Dugley DoRight

    New Member

  • Members
  • Pip
  • 5 posts
  • LocationSeattle, Washington

Posted 07 December 2011 - 07:52 PM

I've been programming longer than B. Gates but I'm completely new to Visual Studio and dot net so please excuse this dumb question from an old noob. I've downloaded netmftoolbox-11191.zip and I must say that the code looks very nice and should suit my needs wonderfully. But... What do I do with the zip file? Where do I unzip/install it to? And how do I reference the classes? Sorry about being completely clueless. "Those who say something is impossible should get out of the way of those who are doing it." Dugley

#13 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 07 December 2011 - 08:20 PM

Hi Dugley and welcome to the Netduino forums :)

There are actually a few ways to deal with this.

The detailed way: This way all source code is available and yet in another project
1. extract the zip -somewhere- to your system. Let's take D:\Netduino as example, so extract the framework to "D:\Netduino\netmftoolbox"
2. Create a new project for yourself
3. Click in the top menu: File -> Add -> Existing Project
4. Browse to "D:\Netduino\netmftoolbox\Framework\Toolbox.NETMF.csproj"
4a. Do the same for "Framework\NET\Toolbox.NETMF.NET.csproj" if you need networking classes
4b. Do the same for "Framework\Hardware\Toolbox.NETMF.Hardware.csproj" if you need hardware classes
5. Click in the top menu: Project -> Add Reference -> Projects
6. Select all projects and press OK
7. Add "using Toolbox.NETMF;" at the top of your project
7a. Add "using Toolbox.NETMF.NET;" as well if you need networking classes
7b. Add "using Toolbox.NETMF.Hardware;" as well if you need hardware classes

The DLL-way: This way no source code is available but no other files are added to your project
1. extract the zip -somewhere- to your system. Let's take D:\Netduino as example, so extract the framework to "D:\Netduino\netmftoolbox"
2. Create a new project for yourself
3. Click in the top menu: Project -> Add Reference -> Browse
4. Browse to "D:\Netduino\netmftoolbox\Release\Toolbox.NETMF.dll"
4a. Browse to "D:\Netduino\netmftoolbox\Release\Toolbox.NETMF.NET.dll" as well if you need networking classes
4b. Browse to "D:\Netduino\netmftoolbox\Release\Toolbox.NETMF.Hardware.dll" as well if you need hardware classes
5. Add "using Toolbox.NETMF;" at the top of your project
5a. Add "using Toolbox.NETMF.NET;" as well if you need networking classes
5b. Add "using Toolbox.NETMF.Hardware;" as well if you need hardware classes

Simple way: This way all required files will be embedded in your project
1. extract the zip -somewhere- to your system. Let's take D:\Netduino as example, so extract the framework to "D:\Netduino\netmftoolbox"
2. Create a new project for yourself
3. Click in the top menu: Project -> Add Existing Item
4. Browse to the required classes, for SMTP_Client: "netmftoolbox\Framework\Tools.cs", "netmftoolbox\Framework\NET\SMTP_Client.cs" and "netmftoolbox\Framework\NET\SimpleSocket.cs"
5. Add "using Toolbox.NETMF;" at the top of your project
5a. Add "using Toolbox.NETMF.NET;" as well if you need networking classes
5b. Add "using Toolbox.NETMF.Hardware;" as well if you need hardware classes

Hopefully this helps?
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#14 Dugley DoRight

Dugley DoRight

    New Member

  • Members
  • Pip
  • 5 posts
  • LocationSeattle, Washington

Posted 07 December 2011 - 10:37 PM

Stefan, That was a wonderful, detailed and very quick response. Thank you so much. I was trying to do something much more complicated. Dugley

#15 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 08 December 2011 - 10:52 AM

That was a wonderful, detailed and very quick response. Thank you so much.

It was my 900th post. It had to be worth it right? ;)
I also put it on the documentation of the project itself @ http://netmftoolbox....se the classes? :)

Glad to be of help. Just wondering, what 'much more complicated' things were you trying?
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#16 Dugley DoRight

Dugley DoRight

    New Member

  • Members
  • Pip
  • 5 posts
  • LocationSeattle, Washington

Posted 08 December 2011 - 05:09 PM

It was my 900th post. It had to be worth it right? ;)
I also put it on the documentation of the project itself @ http://netmftoolbox....se the classes? :)

Glad to be of help. Just wondering, what 'much more complicated' things were you trying?


I assumed that you might have to install, register, import or place the files into a particular directory - as you do with eclipse and other programs. Just extracting and referencing stuff seemed too simple and civilised. ;)

Thanks again for the reply.

I will be trying it very soon. With my help you should be able to reach 1000 very soon.

#17 Ellen

Ellen

    Advanced Member

  • Members
  • PipPipPip
  • 65 posts
  • LocationRotterdam, Netherlands

Posted 06 September 2012 - 07:51 AM

Hi :)


Now it's possible to send mails through an SMTP server. The class doesn't have authentication yet, but it works! :D


Stefan, when do you think that authentication will be implement in this class.
I need to sent once a day some data with the netduino but the mail server ask for authentication.
Ellen

#18 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 06 September 2012 - 08:02 AM

Stefan, when do you think that authentication will be implement in this class.
I need to sent once a day some data with the netduino but the mail server ask for authentication.
Ellen

Hi Ellen,

There are two forms of SMTP authentication (not counting TLS/SSL layers).
One is already implemented and supported by most providers. The second one is currently not possible due to a bug that's still unresolved in the .NETMF core: http://netmf.codeple...m/workitem/1321

I could work around that problem for specific cases, if that's required maybe we could work that out?
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#19 rovv

rovv

    New Member

  • Members
  • Pip
  • 3 posts

Posted 15 July 2013 - 02:02 PM

Hi , Stefan  

 

 I  need your help seriously    as I copy your code (the first one above)  and start running it,

 

it is coming out of  [ An unhandled exception of type 'System.NullReferenceException' occurred in NetduinoApplication2.exe ]  

 

   Could you  solve this  stuck   for me please

 

           I'm so appretiate

 

  I   change  3 points from  your original code.

 

add  2  pictures along to you.

 

 

 

Attached Files



#20 rovv

rovv

    New Member

  • Members
  • Pip
  • 3 posts

Posted 17 July 2013 - 12:09 PM

Urrmm..  Stefan

 

I  copy your code  and follow your steps  

 

but finally when debugging  it's come out like this  " An unhandled exception of type 'System.NullReferenceException' occurred in mail.exe"

 

could you   help me resolve this stuck , please

                                                                            Very Thanks

 

We've try this code via Netduino Plus , and Plus 2 boths but the result is the same .

 

We've change one point from your pure code   because it's come out redline line mark at

SMTP_Client Sender = new SMTP_Client("smtp.gmx.com");

i right click and choose Constuctor.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.