0

How can i send a file at my e-mail address?
I want to write it in my C program.
Is there any simple way to do that?

I Use Dev C++ compiler.
I am not using C# or VB.

Thanks in advance for answering.

2
Contributors
11
Replies
17
Views
5 Years
Discussion Span
Last Post by DeanMSands3
Featured Replies
  • Let me explain the [B]system("...")[/B] function. system("x 1 2 3"); calls a program "x" and passes it the parameters 1, 2, and 3. So instead of dropping system() entirely, you'd be doing something like [B]system("blat blah.txt -to [email]somebody@somewhere.com[/email]");[/B] Also note that blat requires a text file to email, otherwise it … Read More

0

What you want to do is likely above your present ability. (For now.)
I'm telling you this kindly.
However, you have asked a question, and I will answer it.
(Who knows, this might be the start of a wonderful new world of socket programming for you.)

First, since you are using Windows, you will want to familiarize yourself with Winsock.
Google windows socket tutorials
You will find a nice tutorial for it here:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=9818&lngWId=3
And a handy reference here:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms738545(v=vs.85).aspx

Code Project is also a fantastic place for finding code examples, but you'll need to register to download.

Since you are using the MinGW compiler (part of Dev-C++), you will need to add -lwsock32 and -lws2_32 in your libraries.

Once you're comfortable with writing socket code, I suggest you have a look at this:
http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol
Have a look at the example exchange in the article. It'll help.

Happy coding!

0

You said,
"What you want to do is likely above your present ability. (For now.)"
Is this because of my experience or i cannot write it in C programming?


I have found a code like this:
system("mailx -s " hello "andr.mark.1@gmail.com");

when i run this code:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>


int main(void)
{

system("mailx -s " hello "andr.mark.1@gmail.com");

system("pause");
exit(0);
return 0;

}

I get these two errors:
C:\Users\Makias\Desktop\Untitled1.cpp In function `int main()':
10 C:\Users\Makias\Desktop\Untitled1.cpp expected `)' before "hello"


Thanks for the links i will give them a look.
I am not experienced so i need a bit more help.

Edited by JilMakias: n/a

0

Why did I say that? The way you worded your question gave me a clue you might be a little green. A semi-seasoned coder would have asked for help in socket programming. They might have even mentioned watching "sendmail" programs inside a WireShark session.
You didn't word yours that way. Instead, you asked for a finished product without realizing it.
Now to business. Your proposed method system("mailx...") calls an outside program (mailx) to send the email. Admittedly, that's a simpler solution I hadn't considered.
Now, mailx is a Unix/Linux program. You can get a Windows version, but it will insist on some Unix-isms you may not be happy with.
I recommend having a look at blat or any other open source email program designed for Windows.
Look over the command-line usage and adjust your system("..."); command accordingly.

Happy coding!

Edited by DeanMSands3: n/a

0

I am a new coder. Student yet.
I just try to make programs that will give
me some new experience. This one will both
give me experience and help me know the temperature
of an area that i need to know.

I appreciate your help, i think this "blat" is a very good idea.

So, should i leave the system(mailx) idea out of my plans?
I prefer C coding. What do you think?

1

Let me explain the system("...") function.
system("x 1 2 3"); calls a program "x" and passes it the parameters 1, 2, and 3.
So instead of dropping system() entirely, you'd be doing something like system("blat blah.txt -to somebody@somewhere.com");

Also note that blat requires a text file to email, otherwise it might not work.
Also, there's a really good chance your email server will mark your file as SPAM. Make sure to check your spam folders regularly. But who knows?

0

I think with blat i will solve my problem, it was really useful.

I run blat -installer something_wrong
It changed smtp server to something_wrong
Did i do anything that might affect my computer's operation in the future?

Thanks again.

0

After some tries i cannot find how blat works,
Blat might solve my problem but i think i am doing something wrong.

My code:

#include <stdio.h>
#include <math.h>
#include <stdlib.h>


int main(void)
{
system("blat -installSMTP mail.google.com andr.mark.1@gmail.com 2 25");
system("blat msg.txt -to andr.mark.1@gmail.com");


system("pause");
exit(0);
return 0;
}

I am a bit confused.

I also tried other ways but maybe i will finally download Visual Studio.


// For those who like scheduled mailing LetterMeLater.com is a nice site.

Edited by JilMakias: n/a

0

any idea of how to use blat and its parameters...???
i use gmail... any help appreciated...

0

Is your blat program in the system path or where your program can find it?

I have my cpp and txt files in the blat\full folder where the exe is, in order to avoid paths and avoiding path errors.

I used cmd to find the way that blat is used abd to know how to insert it.

I had my IP in PBL spamhause blacklist but somehow after an hour it resolved.

Maybe after a message that i send at Yahoo Contact Us .

To sum up and help anyone that might want to do something similar:

First i run cmd.
Sec i used cd to enter the blat folder.
Third i saved settings of smtp server and senders e-mail: how? run...
blat -SaveSettings -f here_write_senders_mail -server here_write_smtp_server -port here_write_smtp_port -try num_times_to_try_and_send_the_mail -profile computers_prof
fourth if needed by server add: -u for_full_email_user_id -pw email_password
Fifth and final i needed to execute:
blat path/my_file -to the_email_of_the_recipient -debug
or at my cpp file:
system(blat path/my_file -to the_email_of_the_recipient -debug);

-debug will show you info that will help you understand if any problem occurs

Edited by JilMakias: More info to help anyone that might need to make something like this.

0

Yeah... that's happened to me. My church was using a free web host and wanted to create a mailer. Much to our surprise....
I've since moved to paid hosting and that's no-longer a problem. But for you, that's not really an option I guess. Sorry to hear it.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.