mail-archives/monodroid/2011-December/007751.html

123 строки
3.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [mono-android] Saving a log file and attaching to an e-mail
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:monodroid%40lists.ximian.com?Subject=%5Bmono-android%5D%20Saving%20a%20log%20file%20and%20attaching%20to%20an%20e-mail&In-Reply-To=009401ccb8f1%24ef2af220%24cd80d660%24%40nc-software.com">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="007741.html">
<LINK REL="Next" HREF="007744.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[mono-android] Saving a log file and attaching to an e-mail</H1>
<B>Jonathan Pryor</B>
<A HREF="mailto:monodroid%40lists.ximian.com?Subject=%5Bmono-android%5D%20Saving%20a%20log%20file%20and%20attaching%20to%20an%20e-mail&In-Reply-To=009401ccb8f1%24ef2af220%24cd80d660%24%40nc-software.com"
TITLE="[mono-android] Saving a log file and attaching to an e-mail">jonp at xamarin.com
</A><BR>
<I>Mon Dec 12 16:05:55 EST 2011</I>
<P><UL>
<LI>Previous message: <A HREF="007741.html">[mono-android] Saving a log file and attaching to an e-mail
</A></li>
<LI>Next message: <A HREF="007744.html">[mono-android] Running devices
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#7751">[ date ]</a>
<a href="thread.html#7751">[ thread ]</a>
<a href="subject.html#7751">[ subject ]</a>
<a href="author.html#7751">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>On Dec 12, 2011, at 12:17 PM, Neal Culiner wrote:
&gt;<i> Anyone see anything wrong with what I&#8217;m doing?
</I>
No. What API level and device are you having problems on? The following nearly identical code works for me:
var recips = new string[] { &quot;<A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">email at example.com</A>&quot; };
string MessageBody = &quot;This is the message body!&quot;;
var intent = new Intent(Intent.ActionSend);
intent
.PutExtra(Intent.ExtraEmail, recips)
.PutExtra(Intent.ExtraSubject, &quot;Android App Bug Report&quot;)
.PutExtra(Intent.ExtraText, String.Format(&quot;{0}\n\n&quot;, MessageBody))
.SetType(&quot;application/octet-stream&quot;);
if (File.Exists(filePath))
{
Java.IO.File file = new Java.IO.File(filePath);
var uri = Android.Net.Uri.FromFile (file);
Log.Info (&quot;*jonp*&quot;, &quot;File URI: {0}&quot;, uri.ToString ());
intent.PutExtra(Intent.ExtraStream, uri);
}
try
{
StartActivity(Intent.CreateChooser(intent, &quot;Send E-mail Using...&quot;));
}
catch (Exception ex)
{
Log.Info (&quot;*jonp*&quot;, &quot;Exception! {0}&quot;, ex);
Toast.MakeText(this, &quot;There are no e-mail clients installed.&quot;, ToastLength.Short).Show();
}
The email I received does contain an attachment that contains data.
Thanks,
- Jon
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="007741.html">[mono-android] Saving a log file and attaching to an e-mail
</A></li>
<LI>Next message: <A HREF="007744.html">[mono-android] Running devices
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#7751">[ date ]</a>
<a href="thread.html#7751">[ thread ]</a>
<a href="subject.html#7751">[ subject ]</a>
<a href="author.html#7751">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/monodroid">More information about the Monodroid
mailing list</a><br>
</body></html>