0
我想發送郵件在xamarin.android.I可以發送文本與下面的代碼沒有圖像,但是當我試圖發送圖像作爲標誌時發生問題。我的意思是,我無法找到圖像的路徑。Xamarin.Android中的圖像路徑
我發送郵件的方法是:
public static void SendMail(List<string> to, List<string> cc, string subject, string body,string mfrom)
{
string messageHeader = "Android E-Mail Testi";
MailMessage msg = new MailMessage();
msg.From = new MailAddress(mfrom);
msg.To.Add(new MailAddress(to[0]));
msg.CC.Add(new MailAddress(cc[0]));
var inlineLogo = new LinkedResource("Drawable://logo.png");//This path is not working.
inlineLogo.ContentId = Guid.NewGuid().ToString();
msg.Body = string.Format(@"<img class=""img-responsive"" src=""cid:{0}"" style=""width:25%; float:left""/>
<br/><br/><h3>" + messageHeader + @"</h3>" + body, inlineLogo.ContentId);
var view = AlternateView.CreateAlternateViewFromString(msg.Body, null, "text/html");
view.LinkedResources.Add(inlineLogo);
msg.AlternateViews.Add(view);
msg.IsBodyHtml = true;
msg.Subject = subject;
msg.SubjectEncoding = Encoding.UTF8;
SmtpClient smtpClient = new SmtpClient("xx.xxx.x.xxx");
msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
List<MemoryStream> mStreams = null;
msg.BodyEncoding = Encoding.Unicode;
smtpClient.Send(msg);
if (mStreams != null)
foreach (MemoryStream mStream in mStreams)
mStream.Close();
}
我可以通過使用asp.net.Only差異這段代碼發送郵件的文件的路徑。我喜歡它,它適用於網頁開發:
var inlineLogo = new LinkedResource(HostingEnvironment.MapPath("~/images/logo.png"));
我應該使用哪種方法用於xamarin中的image(logo.png)路徑?
var inlineLogo = new LinkedResource(???);
我不知道真正的path.How我可以在資源文件夾中的文件夾繪製到達圖像的路徑?
目錄是: