i've created an email app within a WPF but the program times out, i've tried it a few ways with different smtp clients and domains with no luck, please could someone shine some light on where i might be going wrong
[CODE] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Xml; using System.Net.Mail; namespace Email_test { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void button1_Click(object sender, RoutedEventArgs e) { MailMessage mail = new MailMessage(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text); System.Net.NetworkCredential auth = new System.Net.NetworkCredential("my@gmail", "mypassword", "gmail.com"); SmtpClient client = new SmtpClient("smtp.gmail.com",587); client.EnableSsl = false; client.UseDefaultCredentials = false; mail.IsBodyHtml = true; client.Credentials = auth;
The better these AI models get, the more this is going to happen. It's gonna turn into government versus government in regards to using proprietary and unavailable security research models to basically find flaws and vulnerabilities in other governments or companies systems. It's basically turning into a cybersecurity arms race.
This is actually a good thing. The better AI gets, the more restricted and expensive it's going to become, making it far less mainstream. This is good 👍
Question
Sarkhan Vol
i've created an email app within a WPF but the program times out, i've tried it a few ways with different smtp clients and domains with no luck, please could someone shine some light on where i might be going wrong
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
using System.Net.Mail;
namespace Email_test
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
MailMessage mail = new MailMessage(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text);
System.Net.NetworkCredential auth = new System.Net.NetworkCredential("my@gmail", "mypassword", "gmail.com");
SmtpClient client = new SmtpClient("smtp.gmail.com",587);
client.EnableSsl = false;
client.UseDefaultCredentials = false;
mail.IsBodyHtml = true;
client.Credentials = auth;
try {
client.Send(mail);
MessageBox.Show("Success" + Environment.NewLine + "Emai sent", "Close", MessageBoxButton.OK);
}
catch
{
MessageBox.Show("Error" + Environment.NewLine + "Email was not sent", "try again", MessageBoxButton.OK);
}
}
}
}
[/CODE]
Link to comment
https://www.neowin.net/forum/topic/1128656-email-from-wpf-c/Share on other sites
4 answers to this question
Recommended Posts