fixed emali; now working

This commit is contained in:
Wyatt Miller 2018-11-26 03:52:43 -05:00
parent f1b3b9727e
commit 9e5f62952e
13 changed files with 48 additions and 19 deletions

Binary file not shown.

View File

@ -1,19 +1,22 @@
using System; using System;
using System.Net;
using System.Net.Mail;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Controls; using System.Windows.Controls;
using MailKit;
using MailKit.Net.Smtp;
using MailKit.Security;
using MimeKit;
namespace DeskHubSharp namespace DeskHubSharp
{ {
class Email class Email
{ {
// TODO: finish this class // TODO: finish this class
// TODO: debug feedback form
private string _to = "wyatt@wyattjmiller.com"; private string _to = "wjmiller2016@gmail.com";
private string _from = "wjmiller2016@gmail.com"; private string _from = "wjmiller2016@gmail.com";
private string _name; private string _name;
private string _message; private string _message;
@ -50,25 +53,33 @@ namespace DeskHubSharp
{ {
if (IsValidated()) if (IsValidated())
{ {
// TODO: get a test email to send
string subject = $"DeskHubSharp: {_name} requires your attention.";
string body = $"{_message}";
MailMessage message = new MailMessage(_from, _to, subject, body);
SmtpClient client = new SmtpClient("smtp.gmail.com");
//Console.WriteLine("Changing time out from {0} to 100.", client.Timeout);
client.Timeout = 1000;
// Credentials are necessary if the server requires the client
// to authenticate before it will send e-mail on the client's behalf.
client.Credentials = CredentialCache.DefaultNetworkCredentials;
try try
{ {
client.Send(message); var err = new ErrorWindow();
var message = new MimeMessage();
message.From.Add(new MailboxAddress($"{_name}", _from));
message.To.Add(new MailboxAddress("Wyatt J. Miller", _to));
message.Subject = $"{_name} requires your attention!";
message.Body = new TextPart("plain")
{
Text = _message
};
using (var client = new SmtpClient())
{
client.Connect("smtp.gmail.com", 465, SecureSocketOptions.SslOnConnect);
client.Authenticate(_from, "IhaveanAMDRX580");
client.Send(message);
client.Disconnect(true);
}
err.lbl_title.Content = "Thank you!";
err.txtblk_error.Text = "Thank you for sending your email! We have it and will reply shortly.";
err.ShowDialog();
} }
catch (Exception e) catch (Exception e)
{ {
ErrorWindow err = new ErrorWindow(); ErrorWindow err = new ErrorWindow();
Console.WriteLine("Exception caught in CreateTimeoutTestMessage(): {0}", Console.WriteLine("Exception caught in sending message: {0}",
e.ToString()); e.ToString());
err.ShowDialog(); err.ShowDialog();
} }

View File

@ -10,12 +10,17 @@ namespace DeskHubSharp
{ {
class Request class Request
{ {
private string _apiEndpoint = "https://api.github.com/v3/";
public Request() public Request()
{ {
} }
public void SearchRequest()
{
}
} }
} }

View File

@ -35,6 +35,15 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="BouncyCastle.Crypto, Version=1.8.2.0, Culture=neutral, PublicKeyToken=0e99375e54769942">
<HintPath>..\packages\BouncyCastle.1.8.2\lib\BouncyCastle.Crypto.dll</HintPath>
</Reference>
<Reference Include="MailKit, Version=2.0.0.0, Culture=neutral, PublicKeyToken=4e064fe7c44a8f1b, processorArchitecture=MSIL">
<HintPath>..\packages\MailKit.2.0.7\lib\net45\MailKit.dll</HintPath>
</Reference>
<Reference Include="MimeKit, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bede1c8a46c66814, processorArchitecture=MSIL">
<HintPath>..\packages\MimeKit.2.0.6\lib\net45\MimeKit.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
@ -43,6 +52,7 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Security" />
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />

View File

@ -1 +1 @@
96be73db692ee81a8077a343a13bb0e84e99fc14 b453599d59232d67f8d66bb03989d81f4cf64751

View File

@ -13,7 +13,7 @@ C:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\App.xaml
7-86569338 7-86569338
21133474928 21133474928
16-2010050379 20415715258
AboutWindow.xaml;DetailWindow.xaml;ErrorWindow.xaml;FeedbackWindow.xaml;HelpWindow.xaml;MainWindow.xaml;SearchWindow.xaml; AboutWindow.xaml;DetailWindow.xaml;ErrorWindow.xaml;FeedbackWindow.xaml;HelpWindow.xaml;MainWindow.xaml;SearchWindow.xaml;
False False

View File

@ -13,7 +13,7 @@ C:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\App.xaml
7-86569338 7-86569338
25-65043429 25-65043429
16-2010050379 20415715258
AboutWindow.xaml;DetailWindow.xaml;ErrorWindow.xaml;FeedbackWindow.xaml;HelpWindow.xaml;MainWindow.xaml;SearchWindow.xaml; AboutWindow.xaml;DetailWindow.xaml;ErrorWindow.xaml;FeedbackWindow.xaml;HelpWindow.xaml;MainWindow.xaml;SearchWindow.xaml;
True True

View File

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="BouncyCastle" version="1.8.2" targetFramework="net461" />
<package id="MailKit" version="2.0.7" targetFramework="net461" />
<package id="MimeKit" version="2.0.6" targetFramework="net461" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" /> <package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" />
<package id="RestSharp" version="106.5.4" targetFramework="net461" /> <package id="RestSharp" version="106.5.4" targetFramework="net461" />
</packages> </packages>