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 widgets update is merely putting lipstick on a pig. If they actually give a damn about making reliable widgets, they should bring back the 100% offline widgets functionality from Windows 7, just like every other platform offers today. Until then, it's just lipstick after lipstick on the same ads junkyard pig.
The rest feature updates, those are good and welcome improvements.
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