okay dann poste ich hier mal alle Codes, die ich gefunden habe^^
Compiler: Dev C++
Code für: C#
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Mail;
namespace mailer
{
class Program
{
static void Main(string[] args)
{
try {
MailAddress from = new MailAddress("mail@from.com", "from name");
MailAddress to = new MailAddress("mail@to.com", "to name");
MailMessage message = new MailMessage(from, to);
message.Subject = "Our Subject";
message.Body = "This is a message from Kintaro...";
SmtpClient emailClient = new SmtpClient("smtp.meinserver.com", 587);
System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("loginname", "loginpasswort");
emailClient.UseDefaultCredentials = false;
emailClient.Credentials = SMTPUserInfo;
emailClient.Send(message);
Console.WriteLine("Message Sent");
} catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
}
}
}
Fehlercode:
Code:
C:/Dev-Cpp/dev/mail.cpp:1: error: syntax error before `;' token
C:/Dev-Cpp/dev/mail.cpp:10: error: `string' was not declared in this scope
C:/Dev-Cpp/dev/mail.cpp:10: error: syntax error before `]' token
C:/Dev-Cpp/dev/mail.cpp:9: warning: all member functions in class `
mailer::Program' are private
C:/Dev-Cpp/dev/mail.cpp: In static member function `static void
mailer::Program::Main(...)':
C:/Dev-Cpp/dev/mail.cpp:14: error: `MailAddress' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:14: error: (Each undeclared identifier is reported only
once for each function it appears in.)
C:/Dev-Cpp/dev/mail.cpp:14: error: syntax error before `}' token
C:/Dev-Cpp/dev/mail.cpp:16: error: `MailMessage' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:17: error: `message' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:20: error: `SmtpClient' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:20: error: syntax error before `}' token
C:/Dev-Cpp/dev/mail.cpp:21: error: `System' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:21: error: syntax error before `}' token
C:/Dev-Cpp/dev/mail.cpp:22: error: `emailClient' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:23: error: `SMTPUserInfo' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:25: error: `Console' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:27: error: syntax error before `}' token
C:/Dev-Cpp/dev/mail.cpp: At global scope:
C:/Dev-Cpp/dev/mail.cpp:30: error: parse error at end of saved function text
Code für: C++ (<- hab ka, warum der dann nicht funzt -.-)
Code:
int _tmain(void)
{
LPMAPISENDMAIL pfnSendMail;
MapiRecipDesc rdOriginator;
MapiRecipDesc rdRecipient[1];
LPMAPILOGOFF pfnLogoff;
LPMAPILOGON pfnLogon;
MapiMessage mapimsg;
HINSTANCE hDll;
LHANDLE lHnd;
MapiFileDesc mapifiledesc[2];
if(NULL == (hDll = LoadLibrary(TEXT("MAPI32.DLL"))))
{
_tprintf(TEXT("could not load mapi32.dll, ErrorCode: %u"), GetLastError());
return(0);
}
// Die Funktionen aus der DLL holen
pfnLogon = (LPMAPILOGON)GetProcAddress(hDll, "MAPILogon");
pfnLogoff = (LPMAPILOGOFF)GetProcAddress(hDll, "MAPILogoff");
pfnSendMail = (LPMAPISENDMAIL)GetProcAddress(hDll, "MAPISendMail");
pfnLogon(0, NULL, NULL, 0, 0, &lHnd); // Einloggen
mapimsg.ulReserved = 0;
mapimsg.lpszSubject = "Subject";
mapimsg.lpszNoteText = "Hi!\n\nAnbei ist eine Datei!\n\nGruß\nIch\n"; // EMailtext
mapimsg.lpszMessageType = NULL;
mapimsg.lpszDateReceived = NULL;
mapimsg.lpszConversationID = NULL;
mapimsg.flFlags = 0;
mapimsg.lpOriginator = &rdOriginator;
mapimsg.nRecipCount = NUM_ELEMENTS(rdRecipient);
mapimsg.lpRecips = rdRecipient;
mapimsg.nFileCount = 2; //2 Dateien anhängen
mapimsg.lpFiles = &mapifiledesc[0];
rdOriginator.ulReserved = 0;
rdOriginator.ulRecipClass = MAPI_ORIG;
rdOriginator.lpszName = "rdOriginator";
rdOriginator.lpszAddress = "ich@sender.de"; // Sender
rdOriginator.ulEIDSize = 0;
rdOriginator.lpEntryID = NULL;
rdRecipient[0].ulReserved = 0;
rdRecipient[0].ulRecipClass = MAPI_TO;
rdRecipient[0].lpszName = "Empfängername"; // Empfängername
rdRecipient[0].lpszAddress = "SMTP:ich@empfaenger.de"; // Empfängeradresse
rdRecipient[0].ulEIDSize = 0;
rdRecipient[0].lpEntryID = NULL;
mapifiledesc[0].ulReserved = 0;
mapifiledesc[0].flFlags = 0;
mapifiledesc[0].nPosition = -1;
mapifiledesc[0].lpszPathName = "C:\\Autostart.bat"; // Die erste Datei
// so heisst die Datei im Anhang des EMails
mapifiledesc[0].lpszFileName = "Datei.txt";
mapifiledesc[0].lpFileType = 0;
// Für die 2te Datei kann man sich dann hierauf beschränken:
mapifiledesc[1].ulReserved = 0;
mapifiledesc[1].flFlags = 0;
mapifiledesc[1].nPosition = -1;
mapifiledesc[1].lpszPathName = "C:\\Bootlog.txt"; // Die zweite Datei
mapifiledesc[1].lpszFileName = "Log.txt";
mapifiledesc[1].lpFileType = 0;
pfnSendMail(lHnd, NULL, &mapimsg, 0, 0); // Das eigentliche Versenden
pfnLogoff(lHnd, 0, 0, 0); // Ausloggen
FreeLibrary(hDll);
return(0);
}
Fehlercode:
Code:
C:/Dev-Cpp/dev/mail.cpp:3: error: `LPMAPISENDMAIL' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:3: error: (Each undeclared identifier is reported only
once for each function it appears in.)
C:/Dev-Cpp/dev/mail.cpp:3: error: syntax error before `;' token
C:/Dev-Cpp/dev/mail.cpp:4: error: `MapiRecipDesc' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:6: error: `LPMAPILOGOFF' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:7: error: `LPMAPILOGON' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:8: error: `MapiMessage' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:9: error: `HINSTANCE' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:10: error: `LHANDLE' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:11: error: `MapiFileDesc' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:13: error: `NULL' undeclared (first use this function)
C:/Dev-Cpp/dev/mail.cpp:13: error: `hDll' undeclared (first use this function)
C:/Dev-Cpp/dev/mail.cpp:13: error: `TEXT' undeclared (first use this function)
C:/Dev-Cpp/dev/mail.cpp:13: error: `LoadLibrary' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:15: error: `GetLastError' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:15: error: `_tprintf' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:20: error: `pfnLogon' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:20: error: syntax error before `(' token
C:/Dev-Cpp/dev/mail.cpp:21: error: `pfnLogoff' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:21: error: syntax error before `(' token
C:/Dev-Cpp/dev/mail.cpp:22: error: `pfnSendMail' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:22: error: syntax error before `(' token
C:/Dev-Cpp/dev/mail.cpp:24: error: `lHnd' undeclared (first use this function)
C:/Dev-Cpp/dev/mail.cpp:26: error: `mapimsg' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:33: error: `rdOriginator' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:34: error: `rdRecipient' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:34: error: `NUM_ELEMENTS' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:37: error: `mapifiledesc' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:40: error: `MAPI_ORIG' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:47: error: `MAPI_TO' undeclared (first use this
function)
C:/Dev-Cpp/dev/mail.cpp:73: error: `FreeLibrary' undeclared (first use this
function)
PS: Bin nen totaler C++ Neuling und habe erst damit angefangen! Codes nur im World Wide Web gefunden...
Mfg