Hello. I am fairly new to this and I am trying to send an email with the FEZ Cobra II and I am having a bit of trouble. I have found several forums online about it but they seemed incomplete, in that they couldnt help me get this working. Here is the code I am using now:
using System;
using Microsoft.SPOT;
using Toolbox.NETMF.NET;
using Toolbox.NETMF;
using System.Threading;
using Microsoft.SPOT.Net;
using Microsoft.SPOT.Net.NetworkInformation;
namespace MFConsoleApplication1
{
public class Program
{
public static void Main()
{
Debug.Print("working");
// Defines the sender
SMTP_Client.MailContact From = new SMTP_Client.MailContact("testercode@ gmail.com", "herron");
// Defines the receiver
SMTP_Client.MailContact Receiver = new SMTP_Client.MailContact("testercode@ gmail.com", "receiver");
// 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
//string smtp = "smtp.gmail.com";
string smtp = "server: aspmx.l.google.com" /*smtp.gmail.com tried this too*/ ;
string username = "testcode";
string pass = "Testercode7";
SMTP_Client.AuthenticationTypes authtype = SMTP_Client.AuthenticationTypes.None;
SMTP_Client Sender = new SMTP_Client(new IntegratedSocket(smtp, 25 /*465*/), authtype, username, pass);
{
//not sure what this host stuff is doing
// By default we fill the hostname with the name of the hardware itself. We need this to identify ourself
string Hostname = Tools.HardwareProvider.ToString();
int LastDot = Hostname.LastIndexOf('.');
//JJ start
if (LastDot > 0)
//JJ end
Hostname = Hostname.Substring(0, LastDot);
//JJ start
}
Sender.Send(Message, From, Receiver)
I forgot to say that I am getting this error
An unhandled exception of type ‘System.ArgumentOutOfRangeException’ occurred in mscorlib.dll
it seems to be where the object “Sender” is created
thanks
As Andre says, when you are pasting code into the forum, make sure you use CODE tags. Edit your post (use the pencil icon on the top right of your existing post that has code in it), then highlight just the code in question, hit the top left 101010 button (not the orange one below the text) and re-submit.
http://netmftoolbox.codeplex.com/wikipage?title=Toolbox.NETMF.NET.SMTP_Client is where you’re using the SMTP library from. I can’t say I’ve seen any discussion here on using this, but it shouldn’t be overly complex. I can also see that there’s not any discussion on issues with this on the codeplex site - although there’s not much discussion on the toolbox at all
As I said, don’t know if too many people will have direct experience on this here, but some might be able to give it a try to see if they get the same issue.
OK, so step 1, please tell us about your network. Are you using Wifi or wired? Have you used your Cobra2 on the network before in any way? Do you have the networking set up at all - your code doesn’t seem to include any IP related setup, and that’s a possible cause of the issue.
hello brett. I am using ethernet, though I just did not put up that part of the code. Do you think that is what is causing the trouble? Thanks for the help.
Ive stepped through and it stops there. I have a feeling it has to do with the socket, that may only be because I dont know much about it but does it matter if I do Simple or integrated. and when you do simple without the username and password, where is it sent?? thanks