Email


Email

Wintempla provides the Sys::EMail class to store an email. Additionaly, the Mt::Smtp class allows sending email using SMTP. The Mt::Smtp class implements the Mt::IThread interface, thus, it is possible to call ThreadFunc directly, or use a Mt::ThreadObject object to call the function using another thread.
Wintempla proporciona la clase Sys::EMail para almacenar un correo electrónico. Adicionalmente, la clase Mt::Smtp permite enviar correo electrónico usando SMTP. La clase Mt::Smtp implementa la interface Mt::IThread, así, es posible llamar directamente ThreadFunc, o usar un objeto de la clase Mt::ThreadObject para llamar la función en otra thread.

Problem 1
Create a Dialog Wintempla application with sockets support called MiCorreo to send email using SMTP. Remember to check the Socket Support option when creating the project.
Cree una aplicación de diálogo de Wintempla con soporte de sockets llamada MiCorreo para enviar correo electrónico usando SMTP. Recuerde de marcar la opción de Suporte para Sockets al crear el proyecto.

MiCorreo.cpp
...
void MiCorreo::Window_Open(Win::Event& e)
{     
     //_____________________________________________ Prepare message
     Sys::EMail email;
     email.toEmail = L"friend@hotmail.com";
     email.toName = L"Friend LastName";
     //
     email.fromEmail = L"johny@yahoo.ca";
     email.fromName = L"John Doe";
     //
     email.subject = L"Hey";
     email.isHtmlFormat = true;
     email.attachmentFileName = L"info.xlsx";
     email.body = L"<html>hola</html>";

     //_____________________________________________ Send message
     Mt::Smtp smtp;
     smtp.emailList.push_back(email);
     smtp.Setup(L"myserver", L"username", L"password", 25, false, 0);
     //smtp.Setup(L"smtp.mail.yahoo.ca", L"johny@yahoo.ca", L"password", 465, true, SP_PROT_SSL3);
     Mt::DoubleTs progress;
     Mt::BoolTs running, resetTime;
     smtp.ThreadFunc(running, progress, resetTime);
     //
     if (smtp.emailList[0].sent == false)
     {
          this->MessageBox(L"Unable to send message", L"MiCorreo", MB_OK     | MB_ICONERROR);
     }
     const wchar_t* error = smtp.GetErrorDescr();
     if (wcslen(error) > 0)
     {
          this->MessageBox(smtp.GetErrorDescr(), L"MiCorreo", MB_OK     | MB_ICONERROR);
     }
}

© Copyright 2000-2021 Wintempla selo. All Rights Reserved. Jul 22 2021. Home