Foros del Web » Programación para mayores de 30 ;) » .NET »

Ayuda Con formato envio correo

Estas en el tema de Ayuda Con formato envio correo en el foro de .NET en Foros del Web. Hola mi consulta es la siguiente, e creado una aplicacion que enviara correos,pero tengo problemas para que mantenga el formato ingresado por el usuario por ...
  #1 (permalink)  
Antiguo 01/12/2010, 13:46
 
Fecha de Ingreso: diciembre-2010
Mensajes: 3
Antigüedad: 13 años, 4 meses
Puntos: 0
Ayuda Con formato envio correo

Hola mi consulta es la siguiente, e creado una aplicacion que enviara correos,pero tengo problemas para que mantenga el formato ingresado por el usuario por ejemplo

INGRESO LAS LETRAS CON ARIAL Y CON COLOR NEGRO OTRAS CON AZUL Y OTRO FORMATO AL CORREO ME LLEGA TODO CON EL MISMO COLOR Y LA MISMA FUENTE


COMO LO PUEDO HACER PARA QUE EL CORREO MANTENGA EL ORDEN QUE LE DIO EL USUARIO
ESPERO SUS RESPUESTA DE ANTEMANO MUCHAS GRACIAS

ESTE ES EL CODIGO QUE TENGO

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Net.Mail;
using System.Net.Mime;
using System.Text.RegularExpressions;
using System.Net;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Anatrinp
{
public partial class EnvioCorreo : Form
{
string EligeColor;
string OrdenaTexto;
public EnvioCorreo()
{
InitializeComponent();
}

private void btEnviar_Click(object sender, EventArgs e)
{

SmtpClient client = new SmtpClient();

client.DeliveryMethod = SmtpDeliveryMethod.Network;

client.EnableSsl = true;

client.Host = "smtp.gmail.com";

client.Port = 587;


// Crear la vista HTML del mail, notar lo que se pone en el tag "img"

AlternateView html = AlternateView.CreateAlternateViewFromString(@"<h1> </h1><img src=""cid:buayacorp_logo"" /><br /><p><TD VALIGN=MIDDLE ALIGN=" + rtbMensage.SelectionAlignment + "><FONT face=" + rtbMensage.Font.Name + " color=" + EligeColor + " size=" + rtbMensage.Font.Size + ">" + rtbMensage.Text + "</p>", Encoding.UTF8, "text/html");



// Crear la vista de texto plano, siempre es bueno para aquellos que no les gusta el HTML

AlternateView texto = AlternateView.CreateAlternateViewFromString("Buaya Corp\n\nTexto plano", Encoding.UTF8, "text/html");
// Adjuntar el recurso logo.jpg, con id "buayacorp_logo" a la vista HTML

LinkedResource logo = new LinkedResource(@"C:\DIRECCION IMAGEN");

logo.ContentId = "buayacorp_logo";

html.LinkedResources.Add(logo);






System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("[email protected]", "CONTRASEÑA");

client.UseDefaultCredentials = false;

client.Credentials = credentials;

string PathFile = tbAdjunto.Text;
string PathFile2 = tbAdjunto2.Text;

MailMessage msg = new MailMessage();
//msg.Attachments.Add(inline);
// Añadir las 2 vistas del correo

msg.AlternateViews.Add(texto);

msg.AlternateViews.Add(html);

msg.From = new MailAddress("[email protected]");//el que envia el correo

msg.To.Add(new MailAddress("[email protected]"));// destinatario

msg.Subject = tbAsunto.Text;

msg.IsBodyHtml = true;

//msg.Body=string.Format("<html><head></head>"+rtbMensage.Text+"<body><b></b></body>"); ;



if (tbAdjunto.Text != "")
{
//agrega primer adjunto
//Agrego el archivo que puse en la ruta anterior "PathFile", y su tipo.
Attachment Data = new Attachment(PathFile, MediaTypeNames.Application.Zip);

//Obtengo las propiedades del archivo.
ContentDisposition disposition = Data.ContentDisposition;
disposition.CreationDate = System.IO.File.GetCreationTime(PathFile);
disposition.ModificationDate = System.IO.File.GetLastWriteTime(PathFile);
disposition.ReadDate = System.IO.File.GetLastAccessTime(PathFile);
//Agrego el archivo al mensaje
msg.Attachments.Add(Data);
if (tbAdjunto2.Text != "")
{
//Agrega segundo Adjunto
//Agrego el archivo que puse en la ruta anterior "PathFile", y su tipo.
Attachment Data2 = new Attachment(PathFile2, MediaTypeNames.Application.Zip);

//Obtengo las propiedades del archivo.
ContentDisposition disposition2 = Data.ContentDisposition;
disposition.CreationDate = System.IO.File.GetCreationTime(PathFile2);
disposition.ModificationDate = System.IO.File.GetLastWriteTime(PathFile2);
disposition.ReadDate = System.IO.File.GetLastAccessTime(PathFile2);
//Agrego el archivo al mensaje
msg.Attachments.Add(Data2);
}
}

try
{

client.Send(msg);
MessageBox.Show("mail enviado Correctamente");
}

catch (Exception ex)
{

MessageBox.Show("Error Nose Pudo Enviar El Mail." + ex.Message);

}


}

private void btExaminar_Click(object sender, EventArgs e)
{
DialogResult result = openFileDialog1.ShowDialog(); // Show the dialog and get result.
if (result == DialogResult.OK) // Test result.
{
try
{
tbAdjunto.Text = openFileDialog1.FileName;
}
catch (IOException)
{
}

}
Console.WriteLine(result); // <-- For debugging use only.

}

private void button1_Click(object sender, EventArgs e)
{
this.Close();
}

private void btExaminar2_Click(object sender, EventArgs e)
{
DialogResult result = openFileDialog1.ShowDialog(); // Show the dialog and get result.
if (result == DialogResult.OK) // Test result.
{
try
{
tbAdjunto2.Text = openFileDialog1.FileName;
}
catch (IOException)
{
}

}
Console.WriteLine(result); // <-- For debugging use only.
}


private void cambiarFuenteToolStripMenuItem_Click(object sender, EventArgs e)//Cambia La Fuente del Correo
{
if (fontDialog1.ShowDialog() == DialogResult.OK)
{

rtbMensage.Font = fontDialog1.Font;
}
}

private void ordenarToolStripMenuItem_Click(object sender, EventArgs e)
{

}
private void button1_Click_1(object sender, EventArgs e)
{
this.Close();
}

private void salirToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void verdeToolStripMenuItem_Click(object sender, EventArgs e)
{
EligeColor = "#01DF01";
}

private void btLime_Click_2(object sender, EventArgs e)
{
EligeColor = "#01DF01";
rtbMensage.SelectionColor = System.Drawing.Color.Lime;
}


private void btBlack_Click(object sender, EventArgs e)
{
EligeColor = "#000000";
rtbMensage.SelectionColor = System.Drawing.Color.Black;
}

private void btRed_Click(object sender, EventArgs e)
{
EligeColor = "#FF0000";
rtbMensage.SelectionColor = System.Drawing.Color.Red;
}

private void btBlue_Click(object sender, EventArgs e)
{
EligeColor = "#0101DF";
rtbMensage.SelectionColor = System.Drawing.Color.Blue;
}

private void btYelow_Click(object sender, EventArgs e)
{
EligeColor = "#FFFF00";
rtbMensage.SelectionColor= System.Drawing.Color.Yellow;
}

private void button1_Click_2(object sender, EventArgs e)
{
OrdenaTexto = "LEFT";
rtbMensage.SelectionAlignment = HorizontalAlignment.Left;
}

private void button3_Click(object sender, EventArgs e)
{
OrdenaTexto = "CENTER";
rtbMensage.SelectionAlignment = HorizontalAlignment.Center;
}

private void btAlineaDerecha_Click(object sender, EventArgs e)
{
OrdenaTexto = "RIGHT";
rtbMensage.SelectionAlignment = HorizontalAlignment.Right;
}

private void btAlinearAjusteHoja_Click(object sender, EventArgs e)
{
OrdenaTexto = "JUSTIFY";

}

}
}

Etiquetas: correo, envio, formato
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:21.