private FilterInfoCollection VideoCaptureDevices; private VideoCaptureDevice FinalVideo; private void mail_Load(object sender, EventArgs e) { //เปิดกล้อง VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); foreach (FilterInfo VideoCaptureDevice in VideoCaptureDevices) { comboBox1.Items.Add(VideoCaptureDevice.Name); } comboBox1.SelectedIndex = 0; FinalVideo = new VideoCaptureDevice(VideoCaptureDevices[comboBox1.SelectedIndex].MonikerString); FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame); FinalVideo.Start(); //ส่วนบันทึกภาพ SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.FileName = "Image"; if (saveFileDialog1.FileName != "") { pictureBox1.Image.Save("D:\\pic.png", System.Drawing.Imaging.ImageFormat.Png); } //ส่วนส่งเมล์ MailAddress mailTo = new MailAddress(toMail); // mailTO เก็บ mail ผู้รับ MailAddress mailFrom = new MailAddress(userID); // mailFrom เก็บ mail ผู้ส่ง MailMessage message = new MailMessage(mailFrom, mailTo); // เอา ผู้ส่ง,ผู้รับ ไว้กับ massge Attachment mailAttach = new Attachment("D:\\pic.png"); //แนบไฟล์กับ mail message.Attachments.Add(mailAttach); message.IsBodyHtml = true; message.Subject = "ตรวจสอบ"; message.Body = DateTime.Now.ToLongTimeString(); SmtpClient client = new SmtpClient(smtpServer, smtpPort); client.EnableSsl = true; client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential(userID, password); try { client.Send(message); MessageBox.Show(string.Format("Sent to: {0} complete.", toMail)); } catch (Exception ex) { MessageBox.Show(string.Format("Error: {0}", ex.Message)); } } //ฟังก์ชันเปิดกล้อง void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs) { Bitmap video = (Bitmap)eventArgs.Frame.Clone(); pictureBox1.Image = video; }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง