genielabs / HomeGenie

HomeGenie, the programmable automation intelligence
https://homegenie.it
GNU General Public License v3.0
388 stars 155 forks source link

Email notification with picture attachments not working on 1.2 beta v14 #342

Closed mralapete closed 5 years ago

mralapete commented 5 years ago

The following CSharp program is working on 1.1 Stable v527 but not on 1.2 beta v14. Email being sent with the alarm condition but no picture attachments

// when the widget button is pressed, an e-mail is sent with pictures from cameras

// This app works for the following 2 FOSCAM IP cameras: // FI8910W: http://.myfoscam.org:/snapshot.cgi?user=&pwd= // FI9821W: http://.myfoscam.org:/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=&pwd=&

// tried calling data from Generic IP Camera app - nothing happened (no error, nothing), although the URL // worked fine in a browser: // byte[] img = Net.Webservice(http:///api/Media.IpCamera/1/Camera.GetPicture).GetBytes();

// When I tried .WithCredentials, the e-mail was NOT sent - error message displayed.

var subject = Program.InputField("Email.Subject").Value; var recipients = Program.InputField("Email.Recipients").Value; var messageText = Program.InputField("Email.Message").Value; var cameraOneImageURL = Program.InputField("IPCamera.ImageURLOne").Value; //var cameraOneUsername = Program.InputField("IPCamera.UsernameOne").Value; //var cameraOnePassword = Program.InputField("IPCamera.PasswordOne").Value; var cameraTwoImageURL = Program.InputField("IPCamera.ImageURLTwo").Value;

if ((recipients != "") && (messageText != "")) { Program.RunAsyncTask(() => { byte[] img; for (int x=0; x<3; x++) { if (cameraOneImageURL != "") { img = Net.WebService(cameraOneImageURL) // .WithCredentials(cameraOneUsername, cameraOnePassword) .GetBytes(); Net.AddAttachment( "first"+x+".jpg", img ); } if (cameraTwoImageURL != "") { img = Net.WebService(cameraTwoImageURL) .GetBytes(); Net.AddAttachment( "second"+x+".jpg", img ); } Pause(1); }

if (Net.SendMessage(recipients, subject, messageText) == true)
  Program.Notify("E-Mail Pictures", "SUCCESS! Pictures sent.");
else Program.Notify("E-Mail Pictures", "ERROR: Pictures **NOT** sent.");

}); } else Program.Notify("E-Mail Pictures", "ERROR: Missing input field(s) - recipients and/or message text.");

Is there something missing in the package manager with the current HG version. Is it an issue with the .Net Helper Class

tuicemen commented 5 years ago

I should have caught this before issue #337 was closed but I was more concerned with all the user created CSharp programs not even loading. When this loaded I assumed it was working as the others I have did. I can confirm this behaves the same for me on a PI 3B+. I just tested and No email or pics are sent with the alarm trip. I use foscams, easyn, and X10 AirSiight cameras

mralapete commented 5 years ago

Problem with .NetSendMessage using Mono 4x. The only way I think this can be resolved is if the package manager is amended to use Mono 5x instead.

This could be done manually by removing Mono 4x and installing Mono 5x from the Mono project page but it could be very messy. @genemars could you swap out Mono 4x for Mono 5x from the Mono project page to see if this resolves the problem

tuicemen commented 5 years ago

If I use the widget I get the email and pictures but this is not being sent on an alarm condition so I don't think this is a Mono issue. I believe it is related to issue #337.

mralapete commented 5 years ago

@genemars I've manually installed HG using the tarball and added the relevant dependencies including Mono 5. Everything is working fine now.

mralapete commented 5 years ago

@genemars I've manually installed HG via the tarball with all the dependencies and Mono 5 instead of Mono 4. Everything is working fine now

mralapete commented 5 years ago

@genmars Installed HG via the tarball along with dependencies and Mono 5 instead of Mono 4. Everything is working now

mralapete commented 5 years ago

Installed Mono 5 and problem is now resolved.