
Importante Visual C++
Publicado por Carlos (2 intervenciones) el 05/04/2014 01:42:56
Hola a todos,
Estoy programando, es muy sencillo, tengo que enviar un archivo, que cuando recibe un mensaje envíe en un .txt a un mail la información. Eso no es el problema, el problema lo tengo que cuando el programa esta compilado, y envío el .txt, y se tiene que guardar otra vez la información, sale la excepción,de que hay un proceso abierto. Es el proceso de carga del archivo del email. Como cierro ese proceso? Estoy bastante bloqueado, os agradecería cualquier ayuda.
Estoy programando, es muy sencillo, tengo que enviar un archivo, que cuando recibe un mensaje envíe en un .txt a un mail la información. Eso no es el problema, el problema lo tengo que cuando el programa esta compilado, y envío el .txt, y se tiene que guardar otra vez la información, sale la excepción,de que hay un proceso abierto. Es el proceso de carga del archivo del email. Como cierro ese proceso? Estoy bastante bloqueado, os agradecería cualquier ayuda.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
else if (message->Contains("+CMGR:")) // SMS Received
{
StreamWriter^ emailer;
String^ message2=message;
if(message2->Contains("TRIGLOG") && serial_settings_form->EmailState==true)
{
//String^ File_2= "C:\\Documents";
///File::Copy(File_,File_2,true);
//File::Finalize(File_);
//CopyFile(File_1,File_2 , true);
//File^ Fileuse = gcnew File(File_);
//emailer = File::AppendText(File_);
//HANDLE File_;
//File::Open(File_);
try
{
String^ File_= serial_settings_form->GetDirectory()+"\\"+GetLogFileName();
MailMessage^ mail = gcnew MailMessage();
//mail->From = gcnew MailAddress(this->serial_settings_form->email_cont);
mail->From = gcnew MailAddress("@gmail.com");
mail->To->Add(gcnew MailAddress("@gmail.com"));
mail->Subject = "Log file Message";
mail->Body = "This is the Logmail file";
Attachment^ at = gcnew Attachment(File_);
mail->Attachments->Add(at);
//mail->Attachments->;
//mail->Attachments->Clear();
SmtpClient^ smtp = gcnew SmtpClient("smtp.gmail.com",587);
smtp->EnableSsl = true;
smtp->UseDefaultCredentials = true;
smtp->Credentials = gcnew System::Net::NetworkCredential@gmail.com",);
smtp->Send(mail);
File_="C:\\";
mail->Attachments->Clear();
}
catch(Exception^ ex)
{
// Show error message
Windows::Forms::MessageBox::Show("Failed to send email: " + ex->Message, "Error.",
Windows::Forms::MessageBoxButtons::OK, Windows::Forms::MessageBoxIcon::Exclamation);
Windows::Forms::MessageBox::Show("Failed to send email: " + ex->InnerException->Message, "Error.",
Windows::Forms::MessageBoxButtons::OK, Windows::Forms::MessageBoxIcon::Exclamation);
}
//mail->Clear();
}
array<String^>^ tokens = message->Split('\"');
String^ name = user_list_form->GetName(tokens[3]);
message = "SMS from: " + name + " (" + tokens[3] + ")\n";
if (this->serial_settings_form->DisplaySMSesChecked())
{
// Set BLUE LED to ON
this->LEFT_BLUE_event_happened();
// Display message in the richTextBox
richTextBox1->Select(richTextBox1->TextLength, 0);
richTextBox1->SelectionColor = System::Drawing::ColorTranslator::FromHtml("#000000");
richTextBox1->AppendText("[A] " + time_and_date + message);
}
// Log the message to file
if (about_form->IsRegistered())
{
WriteToLog(this->serial_settings_form->GetDirectory(), time_and_date + message);
WriteToCSV(this->serial_settings_form->GetDirectory(), time_string, date_string, message);
}
// Next message is going to be the text of the SMS message
waiting_for_sms = true;
}
Valora esta pregunta


0