Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 28th, 2005, 3:52 PM   #1
FoZ
Newbie
 
Join Date: Oct 2004
Posts: 20
Rep Power: 0 FoZ is on a distinguished road
Mailer problem

#include <fstream>
using namespace std;
#include <windows.h>
#include <winsock2.h>
#define ID_SEND 100
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

char szClassName[ ] = "WindowsApp";
static HINSTANCE wInstance = NULL;
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)

{
HWND hwnd;
MSG messages;
WNDCLASSEX wincl;
wInstance = hThisInstance;


wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);


wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);

if (!RegisterClassEx (&wincl))
return 0;

hwnd = CreateWindowEx (
0,
szClassName,
"AnonyMail Written by FoZ",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
640,
500,
HWND_DESKTOP,
NULL,
hThisInstance,
NULL
);

ShowWindow (hwnd, nFunsterStil);

while (GetMessage (&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}

return messages.wParam;
}


LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND info,sndbtn,totxtbx,frmtxtbx,msgtxtbx,srvrlstbx,mailfrmlbl,mailtolbl,mailmsglbl,srvrlbl,wrnnglbl;
HDC hdcmsgtxtbx;
switch (message)
{
case WM_CREATE:
info = CreateWindowEx(NULL,"Static","With this program you can send an email to anyone on an email server. On hotmail and maybe some others the email is filtered into junk email unless it is from a real email address on that server.",SS_CENTER | WS_CHILD | WS_VISIBLE,2,2, 530,50,hwnd,NULL,wInstance,NULL);
frmtxtbx = CreateWindowEx(NULL,"Edit","",WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL,130,55, 400,20,hwnd,NULL,wInstance,NULL);
totxtbx = CreateWindowEx(NULL,"Edit","",WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL,130,80, 400,20,hwnd,NULL,wInstance,NULL);
msgtxtbx = CreateWindowEx(NULL,"Edit","",WS_CHILD | WS_VISIBLE | ES_AUTOVSCROLL | ES_MULTILINE,130,105, 400,200,hwnd,NULL,wInstance,NULL);
sndbtn = CreateWindowEx(NULL,"Button","Send",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,150,385, 60,25,hwnd,(HMENU)ID_SEND,wInstance,NULL);
srvrlstbx = CreateWindowEx(NULL,"Listbox","Mail servers",WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL | LBS_HASSTRINGS,133,310, 125,75,hwnd,NULL,wInstance,NULL);
SendMessage((HWND)srvrlstbx,(UINT)LB_ADDSTRING,(WPARAM)0,(LPARAM)"@Hotmail.com");
SendMessage((HWND)srvrlstbx,(UINT)LB_ADDSTRING,(WPARAM)1,(LPARAM)"@Yahoo");
/*SendMessage((HWND)srvrlstbx,(UINT)LB_ADDSTRING,(WPARAM)0,(LPARAM)"Email Server #1");
SendMessage((HWND)srvrlstbx,(UINT)LB_ADDSTRING,(WPARAM)0,(LPARAM)"Email Server #2");*/
mailfrmlbl = CreateWindowEx(NULL,"Edit","Mail From:",ES_RIGHT | ES_READONLY | WS_BORDER | WS_CHILD | WS_VISIBLE,5,55, 125,20,hwnd,NULL,wInstance,NULL);
mailtolbl = CreateWindowEx(NULL,"Static","Mail To:",SS_RIGHT | WS_BORDER | WS_CHILD | WS_VISIBLE,5,80, 125,20,hwnd,NULL,wInstance,NULL);
mailmsglbl = CreateWindowEx(NULL,"Static","Message:",SS_RIGHT | WS_BORDER | WS_CHILD | WS_VISIBLE,5,105, 125,20,hwnd,NULL,wInstance,NULL);
srvrlbl = CreateWindowEx(NULL,"Static","Email Server:",SS_RIGHT | WS_BORDER | WS_CHILD | WS_VISIBLE,5,310, 125,20,hwnd,NULL,wInstance,NULL);
wrnnglbl = CreateWindowEx(NULL,"Static","WARNING!! This is not 100% anonymous because if the person you email know what they are doing they can get your IP address so do NOT use this to send malicious emails.",SS_CENTER | WS_BORDER | WS_CHILD | WS_VISIBLE,265,310, 268,80,hwnd,NULL,wInstance,NULL);
break;

case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_SEND:
char frm[255];
char mailfrom[255] = "MAIL FROM:";
char to[255];
char mailto[255] = "RCPT TO:";
char data[50]= "DATA";
char finished[5] = ".";
char msg[2048];
char hi[50] = "HELO server";
char answer[255];
int server;
SendMessage((HWND)frmtxtbx,(UINT)WM_GETTEXT,(WPARAM)255,(LPARAM)frm);
SendMessage((HWND)totxtbx,(UINT)WM_GETTEXT,(WPARAM)255,(LPARAM)to);
SendMessage((HWND)msgtxtbx,(UINT)WM_GETTEXT,(WPARAM)255,(LPARAM)msg);
/*GetWindowText(frmtxtbx,frm,250);
GetWindowText(totxtbx,to,250);
GetWindowText(msgtxtbx,msg,250);*/
server = SendMessage((HWND)srvrlstbx,(UINT)LB_GETCURSEL,(WPARAM)0,(LPARAM)0);
strcat(mailfrom,frm);
strcat(mailto,to);
ofstream file ("C:\\temp.txt",ios::out);
file << hi << endl;
file << mailfrom << endl;
file << mailto << endl;
file << data << endl;
file << msg << endl;
file << finished << endl;
file << server << endl;
file.close();

char address[17];
WSADATA wsadata;
SOCKET sock;
struct sockaddr_in addr;
struct hostent *host;
WSAStartup(514,&wsadata);
host = gethostbyname(address);
memcpy(&addr.sin_addr.s_addr,host->h_addr,host->h_length);
addr.sin_family = AF_INET;
addr.sin_port = htons(250);
if(connect(sock,(sockaddr*)&addr,sizeof(addr)) == SOCKET_ERROR)
{
MessageBox(hwnd,"Could not connect","ERROR!",MB_OK);
closesocket(sock);
WSACleanup();
Sleep(1500);
}
else
/*send(sock,hi,sizeof(hi),0);
recv(sock,answer,sizeof(answer),0);
Sleep(500);
send(sock,mailfrom,sizeof(mailfrom),0);
recv(sock,answer,sizeof(answer),0);
Sleep(500);
send(sock,mailto,sizeof(mailto),0);
recv(sock,answer,sizeof(answer),0);
Sleep(500);
send(sock,data,sizeof(data),0);
recv(sock,answer,sizeof(answer),0);
Sleep(500);
send(sock,msg,sizeof(msg),0);
recv(sock,answer,sizeof(answer),0);
Sleep(500);
send(sock,finished,sizeof(finished),0);
recv(sock,answer,sizeof(answer),0);*/
closesocket(sock);
WSACleanup();
MessageBox(hwnd,"Email sent","Finished",MB_OK);
break;
}
break;

case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}

return 0;
}




Ive tried both the send message and getwindowtext commands to get the text from the edit boxes but none of them work. I cant remember which but 1 get a load of weird characters and 1 gets nothing. Anyone know what is wrong?
FoZ is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:50 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC