Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(MFC) Add File Attachments to an EmailDemonstrates how to add one or more file attachments to an email.
#include <CkEmail.h> void ChilkatSample(void) { CkString strOut; CkEmail email; email.put_Subject("This is a test"); email.put_Body("This is a test"); email.put_From("support@chilkatsoft.com"); bool success = email.AddTo("Chilkat Admin","admin@chilkatsoft.com"); // To add file attachments to an email, call AddFileAttachment // once for each file to be attached. The method returns // the content-type of the attachment if successful, otherwise // returns cknull const char *contentType = 0; contentType = email.addFileAttachment("something.pdf"); if (email.get_LastMethodSuccess() != true) { strOut.append(email.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } contentType = email.addFileAttachment("something.xml"); if (email.get_LastMethodSuccess() != true) { strOut.append(email.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } contentType = email.addFileAttachment("something.zip"); if (email.get_LastMethodSuccess() != true) { strOut.append(email.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } success = email.SaveEml("email.eml"); if (success == false) { strOut.append(email.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } strOut.append("Saved EML!"); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.