How do I rate a thread?Quote:
Originally posted by sushb4u
can i give any points or like something that??i m new to this forum...thats why i m asking this.
Printable View
How do I rate a thread?Quote:
Originally posted by sushb4u
can i give any points or like something that??i m new to this forum...thats why i m asking this.
It works fine for me, u can additionally include subject etc...Quote:
Originally Posted by Andreas Masur
thank
Hmm...interesting...then it is supposed to be a problem with either my ISP or mail client... :ehh:Quote:
Originally Posted by Tamerocyte
Well...thanks for the information...
Quote:
Originally Posted by sushb4u
You need include this file: #include "stdafx.h" in m.cpp
In the same cases, u need do that, it' Ok
Well, i rly like your code but... Most servers currently need TLS/SSL support, which i do not know how to implement.
:confused:
You realise this threads over 5 years old?
Indeed.
Well, any one has tried sending emails with SMTP Authentication under VIsual C++?
It seems to be a useful feature.
The following one using visual C++ but only support the VC++ 2005 and 2008.
http://www.naughter.com/smtp.html
I like VC++ 6 better for its reliable codes and smaller code size.
"Please note that as of v2.70, the code is now for Visual C++ 2005 or later. I will not be supporting VC 6 anymore for this code, so please don't email me requesting this<gg>. Remember VC 6 is now a ten year old compiler. It's now time to upgrade to VC 2005 or VC 2008!"
Maybe someone can share the V2.70 or earlier edition while the author stopped providing aged releases.
I use this send mail vc++ code but it gives error error during call to recv<> reply:-1 - 10054 and remaing all lines.so give me solution,exactly what is the problem
I'm an old VB6 guy working my way through MSVC. At 56, it's hard to assimilate enough to write MSVC effectively before I'm retirement age! Your generous and cooperative attitude will help more people than you know. Thank you so much.
Hello. When I run the program I get an error message like this. I would be glad if you help. Thank you in advance.
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|10|warning: ignoring #pragma comment |
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|13|error: ISO C++ forbids declaration of 'VERSION_MAJOR' with no type|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|14|error: ISO C++ forbids declaration of 'VERSION_MINOR' with no type|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp||In function 'void ShowUsage()':|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|20|error: 'cout' was not declared in this scope|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|20|error: 'endl' was not declared in this scope|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp||In function 'void Check(int, char*)':|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|32|error: 'cerr' was not declared in this scope|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|32|error: 'endl' was not declared in this scope|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp||In function 'int main(int, char**)':|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|60|error: 'ifstream' was not declared in this scope|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|60|error: expected ';' before 'MsgFile'|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|65|error: 'cout' was not declared in this scope|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|65|error: 'endl' was not declared in this scope|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|74|error: 'cout' was not declared in this scope|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|74|error: 'endl' was not declared in this scope|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|83|error: 'cout' was not declared in this scope|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|83|error: 'endl' was not declared in this scope|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|105|error: 'cout' was not declared in this scope|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|105|error: 'endl' was not declared in this scope|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|111|warning: deprecated conversion from string constant to 'char*'|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|115|warning: deprecated conversion from string constant to 'char*'|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|116|warning: deprecated conversion from string constant to 'char*'|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|120|warning: deprecated conversion from string constant to 'char*'|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|121|warning: deprecated conversion from string constant to 'char*'|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|125|warning: deprecated conversion from string constant to 'char*'|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|126|warning: deprecated conversion from string constant to 'char*'|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|130|warning: deprecated conversion from string constant to 'char*'|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|131|warning: deprecated conversion from string constant to 'char*'|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|134|error: 'MsgFile' was not declared in this scope|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|139|warning: deprecated conversion from string constant to 'char*'|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|145|warning: deprecated conversion from string constant to 'char*'|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|146|warning: deprecated conversion from string constant to 'char*'|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|150|warning: deprecated conversion from string constant to 'char*'|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|151|warning: deprecated conversion from string constant to 'char*'|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|154|error: 'cout' was not declared in this scope|
C:\Users\Hkn\Desktop\calisma\fb\main.cpp|154|error: 'endl' was not declared in this scope|
||=== Build finished: 19 errors, 15 warnings (0 minutes, 0 seconds) ===|
last right, then the error message as follows;
C: \ Users \ HKN \ Desktop \ working \ fb \ main.cpp | 11 | warning: ignoring # pragma comment |
C: \ Users \ HKN \ Desktop \ working \ fb \ main.cpp | 14 | error: ISO C + + forbids declaration of 'VERSION_MAJOR' with no type |
C: \ Users \ HKN \ Desktop \ working \ fb \ main.cpp | 15 | error: ISO C + + forbids declaration of 'VERSION_MINOR' with no type |
Codeblocks in the meantime, I use the IDE.
I am also having the problem with the code errors. The exact same, actually.
I m writting an application which calulates some results and send them thr e-mail.I want my VC++ program to send this mail to specified address without using Outlook Express or Microsoft Outlook...So You try to this link htttp://www.coolinterview.com
Please someone help me im trying 1 week to use this code.
I m getting error on this line : if(connect(hServer, (PSOCKADDR) &SockAddr, sizeof(SockAddr)))
Please see error screenshot
This is my code :
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <stdlib.h>
//#include <fstream.h>
//#include <iostream.h>
#include <windows.h>
#include <winsock2.h>
using namespace std;
#pragma comment(lib, "ws2_32.lib")
// Insist on at least Winsock v1.1
const int VERSION_MAJOR = 1;
const int VERSION_MINOR = 1;
#define CRLF "\r\n" // carriage-return/line feed pair
void ShowUsage(void)
{
cout << "Usage: SENDMAIL mailserv to_addr from_addr messagefile" << endl
<< "Example: SENDMAIL smtp.myisp.com rcvr@elsewhere.com my_id@mydomain.com message.txt" << endl;
exit(1);
}
// Basic error checking for send() and recv() functions
void Check(int iStatus, char *szFunction)
{
if((iStatus != SOCKET_ERROR) && (iStatus))
return;
cerr << "Error during call to " << szFunction << ": " << iStatus << " - " << GetLastError() << endl;
}
int main(int argc, char *argv[])
{
int iProtocolPort = 587;
char szSmtpServerName[64] = "smtp.gmail.com";
char szToAddr[64] = "lester555@gmail.com";
char szFromAddr[64] = "555lester@gmail.com";
char szBuffer[4096] = "lester555@gmail.com";
char szLine[255] = "vai vai vaiiii";
char szMsgLine[255] = "vai vai vaiiii";
SOCKET hServer;
WSADATA WSData;
LPHOSTENT lpHostEntry;
LPSERVENT lpServEntry;
SOCKADDR_IN SockAddr;
argc = 5;
// Check for four command-line args
if(argc != 5)
ShowUsage();
// Load command-line args
lstrcpy(szSmtpServerName, argv[1]);
lstrcpy(szToAddr, argv[2]);
lstrcpy(szFromAddr, argv[3]);
// Create input stream for reading email message file
string dir = "D:\\file.txt";
ifstream MsgFile(dir);
// Attempt to intialize WinSock (1.1 or later)
if(WSAStartup(MAKEWORD(VERSION_MAJOR, VERSION_MINOR), &WSData))
{
cout << "Cannot find Winsock v" << VERSION_MAJOR << "." << VERSION_MINOR << " or later!" << endl;
return 1;
}
// Lookup email server's IP address.
lpHostEntry = gethostbyname(szSmtpServerName);
if(!lpHostEntry)
{
cout << "Cannot find SMTP mail server " << szSmtpServerName << endl;
return 1;
}
// Create a TCP/IP socket, no specific protocol
hServer = socket(PF_INET, SOCK_STREAM, 0);
if(hServer == INVALID_SOCKET)
{
cout << "Cannot open mail server socket" << endl;
return 1;
}
// Get the mail service port
lpServEntry = getservbyname("mail", 0);
// Use the SMTP default port if no other port is specified
if(!lpServEntry)
iProtocolPort = htons(IPPORT_SMTP);
else
iProtocolPort = lpServEntry->s_port;
//iProtocolPort = 587;
// Setup a Socket Address structure
SockAddr.sin_family = AF_INET;
SockAddr.sin_port = iProtocolPort;
SockAddr.sin_addr = *((LPIN_ADDR)*lpHostEntry->h_addr_list);
// Connect the Socket
if(connect(hServer, (PSOCKADDR) &SockAddr, sizeof(SockAddr)))
{
cout << "Error connecting to Server socket" << endl;
DWORD err = ::GetLastError();
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL );
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
cout << (LPCTSTR)lpMsgBuf << endl;
system("pause");
return 1;
}
// Receive initial response from SMTP server
Check(recv(hServer, szBuffer, sizeof(szBuffer), 0), "recv() Reply");
// Send HELO server.com
sprintf(szMsgLine, "HELO %s%s", szSmtpServerName, CRLF);
Check(send(hServer, szMsgLine, strlen(szMsgLine), 0), "send() HELO");
Check(recv(hServer, szBuffer, sizeof(szBuffer), 0), "recv() HELO");
// Send MAIL FROM: <sender@mydomain.com>
sprintf(szMsgLine, "MAIL FROM:<%s>%s", szFromAddr, CRLF);
Check(send(hServer, szMsgLine, strlen(szMsgLine), 0), "send() MAIL FROM");
Check(recv(hServer, szBuffer, sizeof(szBuffer), 0), "recv() MAIL FROM");
// Send RCPT TO: <receiver@domain.com>
sprintf(szMsgLine, "RCPT TO:<%s>%s", szToAddr, CRLF);
Check(send(hServer, szMsgLine, strlen(szMsgLine), 0), "send() RCPT TO");
Check(recv(hServer, szBuffer, sizeof(szBuffer), 0), "recv() RCPT TO");
// Send DATA
sprintf(szMsgLine, "DATA%s", CRLF);
Check(send(hServer, szMsgLine, strlen(szMsgLine), 0), "send() DATA");
Check(recv(hServer, szBuffer, sizeof(szBuffer), 0), "recv() DATA");
// Send all lines of message body (using supplied text file)
MsgFile.getline(szLine, sizeof(szLine)); // Get first line
do // for each line of message text...
{
sprintf(szMsgLine, "%s%s", szLine, CRLF);
Check(send(hServer, szMsgLine, strlen(szMsgLine), 0), "send() message-line");
MsgFile.getline(szLine, sizeof(szLine)); // get next line.
} while(MsgFile.good());
// Send blank line and a period
sprintf(szMsgLine, "%s.%s", CRLF, CRLF);
Check(send(hServer, szMsgLine, strlen(szMsgLine), 0), "send() end-message");
Check(recv(hServer, szBuffer, sizeof(szBuffer), 0), "recv() end-message");
// Send QUIT
sprintf(szMsgLine, "QUIT%s", CRLF);
Check(send(hServer, szMsgLine, strlen(szMsgLine), 0), "send() QUIT");
Check(recv(hServer, szBuffer, sizeof(szBuffer), 0), "recv() QUIT");
// Report message has been sent
cout << "Sent " << argv[4] << " as email message to " << szToAddr << endl;
// Close server socket and prepare to exit.
closesocket(hServer);
WSACleanup();
return 0;
}