Advertisement
Guest User

Untitled

a guest
May 4th, 2015
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #include "easendmailobj.tlh"
  2.  
  3. using namespace EASendMailObjLib;
  4.  
  5. int _tmain(int argc, _TCHAR* argv[])
  6. {
  7.  
  8. ::CoInitialize( NULL );
  9.  
  10. IMailPtr oSmtp = NULL;
  11. oSmtp.CreateInstance( "EASendMailObj.Mail");
  12. oSmtp->LicenseCode = _T("TryIt");
  13.  
  14. // Set your sender email address
  15. oSmtp->FromAddr = _T("ralew1@wp.pl");
  16.  
  17. // Add recipient email address
  18. oSmtp->AddRecipientEx( _T("rabarbar923@gmail.com"), 0 );
  19.  
  20. // Set email subject
  21. oSmtp->Subject = _T("HTML email from Visual C++ project with attachment");
  22.  
  23. // Set HTML body format
  24. oSmtp->BodyFormat = 1;
  25.  
  26. // Set HTML body text
  27. oSmtp->BodyText = _T("<font size=5>This is</font> <font color=red><b>a test</b></font>");
  28.  
  29. // Add attachment from local disk
  30. if(oSmtp->AddAttachment( _T("D:\Fraps\changes.txt")) != 0)
  31. {
  32. _tprintf( _T("Failed to add attachment with error: %s\r\n"),
  33. (const TCHAR*)oSmtp->GetLastErrDescription());
  34. }
  35.  
  36.  
  37.  
  38. // Your SMTP server address
  39. oSmtp->ServerAddr = _T("smtp.wp.pl");
  40.  
  41. oSmtp->UserName = _T("ralew1@wp.pl");
  42. oSmtp->Password = _T("tu bylo moje haslo");
  43.  
  44. oSmtp->SSL_init();
  45.  
  46. _tprintf(_T("Start to send HTML email ...\r\n" ));
  47.  
  48. if( oSmtp->SendMail() == 0 )
  49. {
  50. _tprintf( _T("email was sent successfully!\r\n"));
  51. }
  52. else
  53. {
  54. _tprintf( _T("failed to send email with the following error: %s\r\n"),
  55. (const TCHAR*)oSmtp->GetLastErrDescription());
  56. }
  57.  
  58. if( oSmtp != NULL )
  59. oSmtp.Release();
  60.  
  61. getch();
  62.  
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement