使用emai lto用户发送图像 [英] sending image with emai lto user

查看:75
本文介绍了使用emai lto用户发送图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用此代码发送用户凭据但现在我想发送一张带凭据的图片





i已添加



string path = Server.MapPath(@Images / book-cover.jpg);



但是不工作



请帮忙,在此先感谢...









i have used this code for sending user credential but now i want to send one image with credential


i have add

string path = Server.MapPath(@"Images/book-cover.jpg");

but not working

pls help, thanks in advance...




string sBody = TxtUserName.Text.Trim() + TxtPassword.Text.Trim();
            string path = Server.MapPath(@"Images/book-cover.jpg");

            MailMessage msg = new MailMessage();
            msg.From = "dansingteam@dansingwater.com";
            msg.To = txtEmailID.Text.Trim();
            //MailAddress copy = new MailAddress("vinayak@spareage.com");
            //msg.CC.Add(copy); 
            msg.Subject = "DansingWater Registration Detail";
            msg.Body = ": Welcome to Dansing Water,  Your Credentials are as follows :" + "\r\n" + "User Name :" + TxtUserName.Text.Trim() + "\r\n" + "password : " + TxtPassword.Text.Trim() + "\r\n";
           
            //SmtpClient objClient = new SmtpClient();
            SmtpMail.SmtpServer = "smtp.net4india.com";
            SmtpMail.Send(msg);

推荐答案

你可以使用多部分消息。您的图像应该是编码为base64的单独部分。部分应该具有适当的内容类型内容处理告诉邮件查看器程序如何处理图片(建议下载它或嵌入在邮件内容中显示)。



你可以在课堂上找到它全部 MailMessage

http://msdn.microsoft.com/en-us/library/system.net.mail .mailmessage.aspx [ ^ ]。



需要代码示例吗?如果您这样做,您可以轻松找到一些: http://lmgtfy.com/?q=System.Net.Mail.MailMessage+multipart+with+(image+OR+picture+OR+bitmap) [ ^ ]。



祝你好运,

-SA
You can do it by using multi-part messages. Your image should be a separate part encoded as base64. A part should have appropriate content type and content disposition telling the mail viewer program how to treat the picture (suggest downloading it or show embedded in the message content).

You will be able to find it all in the class MailMessage:
http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx[^].

Need a code sample? You can easily find some if you do this: http://lmgtfy.com/?q=System.Net.Mail.MailMessage+multipart+with+(image+OR+picture+OR+bitmap)[^].

Good luck,
—SA


试试这个代码

try this code
string path = Server.MapPath(@"/WebSiteFolderName/Images/book-cover.jpg");
MailAttachment attach = new MailAttachment(path);
MailMessage msg = new MailMessage();
msg.Attachments.Add(attach);


string sBody = TxtUserName.Text.Trim() + TxtPassword.Text.Trim();
string path = Server.MapPath(@"Images/book-cover.jpg"); 
MailMessage msg = new MailMessage();
MailAttachment attachment = new MailAttachment(path);
msg.Attachments.Add(attachment);

msg.From = "dansingteam@dansingwater.com";
msg.To = txtEmailID.Text.Trim();
//msg.Attachment.Add(attach);
 
//MailAddress copy = new MailAddress("vinayak@spareage.com");
//msg.CC.Add(copy); 
msg.Subject = "DansingWater Registration Detail";
msg.Body = ": Welcome to Dansing Water, Your Credentials are as follows :" + "\r\n" + "User Name :" + TxtUserName.Text.Trim() + "\r\n" + "password : " + TxtPassword.Text.Trim() + "\r\n";

//SmtpClient objClient = new SmtpClient();
SmtpMail.SmtpServer = "smtp.net4india.com";
SmtpMail.Send(msg);


这篇关于使用emai lto用户发送图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆