示例#1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.OptionsMain);
            EditText receiver = FindViewById<EditText> (Resource.Id.eTReceiver);
            EditText EmailSender = FindViewById<EditText> (Resource.Id.eTSender);
            EditText passwd = FindViewById<EditText> (Resource.Id.eTPasswd);

            EditText host = FindViewById<EditText> (Resource.Id.eTHost);
            Button saveOptions = FindViewById<Button> (Resource.Id.BSaveOptions);

            saveOptions.Click += (sender, e) =>
            {
                user neuerUser = new user();

                neuerUser.receiver =  receiver.Text;
                neuerUser.senderEmail = EmailSender.Text;
                neuerUser.pw = passwd.Text;
                neuerUser.host = host.Text;

                BinaryFormatter formatter = new BinaryFormatter();
                string profilePath = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "user.bin");
                var fileStream = new FileStream(profilePath,FileMode.Create,FileAccess.Write,FileShare.None);
                formatter.Serialize(fileStream,neuerUser);
                fileStream.Close();

                Toast.MakeText(this,"Erfolgreich",ToastLength.Long).Show();
                receiver.Text = "";
                EmailSender.Text = "";
                passwd.Text = "";
                host.Text = "";

            };
        }
示例#2
0
 public static user loadUserProfile()
 {
     string profilePath = Path.Combine (Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "user.bin");
     user neuerUser = new user ();
     Stream input = new FileStream (profilePath, FileMode.Open, FileAccess.Read, FileShare.None);
     BinaryFormatter deserializer = new BinaryFormatter ();
     neuerUser = (user)deserializer.Deserialize (input);
     input.Close ();
     return neuerUser;
 }
示例#3
0
 static void sendMail(MemoryStream memoryStream, user neuerUser)
 {
     MailMessage mm = new MailMessage (neuerUser.senderEmail, neuerUser.receiver) {
         Subject = "Rechnung : " + Path.GetFileName (Helpers.getFilePath ()),
         IsBodyHtml = false,
         Body = "Rechnung : " + Path.GetFileName (Helpers.getFilePath ())
     };
     mm.Attachments.Add (new Attachment (memoryStream, Helpers.fileName));
     SmtpClient smtp = new SmtpClient {
         Host = neuerUser.host,
         Port = 587,
         EnableSsl = true,
         Credentials = new NetworkCredential (neuerUser.senderEmail, neuerUser.pw)
     };
     smtp.Send (mm);
 }