diff options
-rw-r--r-- | PollutometerWebApi.userprefs | 5 | ||||
-rw-r--r-- | PollutometerWebApi/Controllers/ReadingsController.cs | 5 | ||||
-rw-r--r-- | PollutometerWebApi/EmailSender.cs | 26 | ||||
-rw-r--r-- | PollutometerWebApi/PollutometerWebApi.csproj | 1 |
4 files changed, 34 insertions, 3 deletions
diff --git a/PollutometerWebApi.userprefs b/PollutometerWebApi.userprefs index 20c987b..f8e05f3 100644 --- a/PollutometerWebApi.userprefs +++ b/PollutometerWebApi.userprefs @@ -1,8 +1,8 @@ <Properties StartupConfiguration="{22C32F4C-0DEB-40EA-9D56-48942CBB2A07}|"> - <MonoDevelop.Ide.Workbench ActiveDocument="PollutometerWebApi/Global.asax.cs"> + <MonoDevelop.Ide.Workbench ActiveDocument="PollutometerWebApi/EmailSender.cs"> <Files> <File FileName="PollutometerWebApi/Controllers/HomeController.cs" Line="2" Column="22" /> - <File FileName="PollutometerWebApi/Controllers/ReadingsController.cs" Line="1" Column="1" /> + <File FileName="PollutometerWebApi/Controllers/ReadingsController.cs" Line="10" Column="31" /> <File FileName="PollutometerWebApi/SqlOperator.cs" Line="1" Column="1" /> <File FileName="PollutometerWebApi/Views/Home/Index.cshtml" Line="1" Column="1" /> <File FileName="PollutometerWebApi/Views/Shared/_Layout.cshtml" Line="1" Column="1" /> @@ -12,6 +12,7 @@ <File FileName="PollutometerWebApi/Web.config" Line="3" Column="33" /> <File FileName="PollutometerWebApi/Global.asax" Line="1" Column="39" /> <File FileName="PollutometerWebApi/Global.asax.cs" Line="1" Column="1" /> + <File FileName="PollutometerWebApi/EmailSender.cs" Line="1" Column="1" /> </Files> </MonoDevelop.Ide.Workbench> <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" /> diff --git a/PollutometerWebApi/Controllers/ReadingsController.cs b/PollutometerWebApi/Controllers/ReadingsController.cs index b692a9c..cb91c71 100644 --- a/PollutometerWebApi/Controllers/ReadingsController.cs +++ b/PollutometerWebApi/Controllers/ReadingsController.cs @@ -7,7 +7,10 @@ namespace PollutometerWebApi.Controllers {
public class ReadingsController : ApiController
{ - public ReadingsController() { } + public ReadingsController()
+ {
+ EmailSender.SendEmail();
+ } public IHttpActionResult GetAllReadings() {
diff --git a/PollutometerWebApi/EmailSender.cs b/PollutometerWebApi/EmailSender.cs new file mode 100644 index 0000000..0e328c9 --- /dev/null +++ b/PollutometerWebApi/EmailSender.cs @@ -0,0 +1,26 @@ +using System; +using System.Net.Mail; + +namespace PollutometerWebApi +{ + public class EmailSender + { + public EmailSender() {} + + public static void SendEmail() + { + MailMessage mail = new MailMessage("***REMOVED***", "***REMOVED***@edu.easj.dk"); + SmtpClient client = new SmtpClient() + { + Host = "mail.cock.li", + Port = 465, + DeliveryMethod = SmtpDeliveryMethod.Network, + UseDefaultCredentials = false, + Credentials = new System.Net.NetworkCredential("***REMOVED***", "***REMOVED***") + }; + mail.Subject = "this is a test email."; + mail.Body = "this is my test email body"; + client.Send(mail); + } + } +}
\ No newline at end of file diff --git a/PollutometerWebApi/PollutometerWebApi.csproj b/PollutometerWebApi/PollutometerWebApi.csproj index a997321..8bde6ba 100644 --- a/PollutometerWebApi/PollutometerWebApi.csproj +++ b/PollutometerWebApi/PollutometerWebApi.csproj @@ -89,6 +89,7 @@ <Compile Include="Controllers\ReadingsController.cs" />
<Compile Include="Models\Reading.cs" />
<Compile Include="SqlOperator.cs" />
+ <Compile Include="EmailSender.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Web.config" />
|