6. Schneller Einstieg
6.4. E-Mail-Versand über SMTP (C++)
#include <windows.h>
#include <CibMail.h>
#include <COMod.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
long t_long;
long t_bool;
long t_result;
char* t_string;
char* errMsg;
long t_iErrorNumber;
t_String = "Hans Mustermann";
t_result = CibMailSetProperty("MailRecipientsFullName", t_String);
t_String = "Hans.Mustermann@gmx.de";
t_result = CibMailSetProperty("MailRecipientsMailBox", t_String);
t_String = "Klaus Meier";
t_result = CibMailSetProperty("MailSenderFullName", t_String);
t_String = "K-Meier@gmx.de";
t_result = CibMailSetProperty("MailSenderMailBox ", t_String);
t_String = "Die gewünschten Urlaubsfotos";
t_result = CibMailSetProperty("MailSubject", t_String);
t_String = "MailText.txt";
t_result = CibMailSetProperty("MailTextFilename", t_String);
t_String = "text/plain";
t_result = CibMailSetProperty("MailTextContentType", t_String);
t_String = "Fotos.pdf";
t_result = CibMailSetProperty("MailAttachmentFilename", t_String);
t_String = "SMTP";
t_result = CibMailSetProperty("MailProtocol", t_String);
// Versenden der eMail
if ( ! CibMailConnect() )
{
CibMailGetLastError(t_iErrorNumber);
printError(t_iErrorNumber);
return t_iErrorNumber;
}
if ( ! CibMailSend() )
{
printError();
}
if ( ! CibMailDisconnect();
{
CibMailGetLastError(t_iErrorNumber);
printError(t_iErrorNumber)
return t_iErrorNumber;
}
printf("eMail erfolgreich versandt!");
return 0;
}
void printError(long a_iErrorNumber)
{
int t_RetVal = 0;
long t_long
char t_Buffer[256];
char* t_ErrorText = t_Buffer
t_long = 256;
CibMailGetErrorText(a_iErrorNumber, t_ErrorText, t_long);
if (t_iErrorNumber != 0 )
{
printf("Fehler %d beim Versenden der eMail: \n%s\n",
t_iErrorNumber, t_ErrorText);
t_RetVal = a_iErrorNumber;
}
return
}