saludos a todos, bueno tengo un problema con un codigo que estoy haciendo para enviar correos con archivo abjunto, cuando adjunto el achivo y lleno todos los datos me marca error en esa parte.
bueno espero alguien me pueda ayudar saludos.
cliente.Send(msg);
codigo completo
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.Mail;
using System.Net;//librerias
using System.Web;//librerias
namespace correo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SmtpClient cliente; //cliente de correo
MailMessage msg; //datos del correo
Attachment anexo; //anexos
private void button3_Click(object sender, EventArgs e)
{
cliente
= new SmtpClient
();
anexo
= new Attachment
(lblArchivoadjunto
.Text);
//datos del correo
msg.Attachments.Add(anexo);
msg.Body = rbtTexto.Text;
msg
.From = new MailAddress
(txtcorreo
.Text); msg.Subject = asuntotxt.Text;
msg.To.Add(txtDestinario.Text);
//credenciales
cliente
.Credentials = new NetworkCredential
(txtcorreo
.Text,txtPass
.Text); cliente.Port = 25;
cliente.Host = comboBox1.Text;
cliente.EnableSsl = true;
cliente.Send(msg);
}
private void adjuntar_Click(object sender, EventArgs e)
{
OpenFileDialog open
= new OpenFileDialog
();
if (open.ShowDialog() == DialogResult.OK) { lblArchivoadjunto.Text = open.FileName; };
}
}
}