Solved

Need code to send email once test is complete

Posted on 2004-09-29
16
294 Views
Last Modified: 2010-05-18
The scenario:

We have numerous people running tests on the same computer throughout the  day.  I have a program that  runs through a test.  Currently it just gives you a pop-up once the test is complete on the test computer.  However, I want to shoot an email off to the tester once the test is complete. I will have to prompt the tester for his email before running the test and save it in a variable which will be used to send it.  I want it to be a generic email stating ' your test is now complete'.  I would like code to do this.  I have searched hi and low and have gotten close but everything I find just opens a new mail message window and you have to send.  I want it to send automatically.   Some explanation with the code would be great as I would like to understand whats going on.  Thanks!!
0
Comment
Question by:mnoel76
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 4
  • +1
16 Comments
 
LVL 86

Assisted Solution

by:jkr
jkr earned 200 total points
ID: 12183153
If you are on Windows,  check out Microsoft's mail command line program at ftp://ftp.microsoft.com/softlib/mslfiles/smplmapi.EXE - it comes with full source code. Also check out the MSKB article at http://support.microsoft.com/default.aspx?scid=kb;en-us;171096 ("FILE: Simple MAPI Console Application"). On UN*X, spawning 'mailx' will help.
0
 
LVL 86

Expert Comment

by:jkr
ID: 12183179
BTW, another alternative might be http://www.codeproject.com/internet/zsmtp.asp ("CFastSmtp - Fast and easy SMTP class..."). Sending a mail can be just like

CFastSmtp mail;

if (mail.ConnectServer("SERVER")) {
    mail.SetSenderName("Sender's Name");
    mail.SetSenderEmail("senders@address.com");
    mail.SetSubject("CFastSmtp v1.1 Release");

    mail.AddRecipient("test@test.com");
    mail.AddCCRecipient("test@test.com");
    mail.AddBCCRecipient("test@test.com");

    mail.SetMessageBody("Here is another test of CFastSmtp SMTP class!");
   
    if (mail.GetConnectStatus()) {        
        printf(mail.Send() ? "Send was a success!" : "Send failed!");
        mail.Disconnect();                    
    }
}  
0
 

Author Comment

by:mnoel76
ID: 12183341
jkr

I will check into tonight as I can not download .exe at work.  I working on windows by the way.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:jkr
ID: 12183389
The CodeProject file is a zipped archive, if you can download that...
0
 
LVL 30

Accepted Solution

by:
Axter earned 300 total points
ID: 12183470
You can also try using the following code:
http://code.axter.com/SendEmail.cpp
http://code.axter.com/SendEmail.h

Above code has a wrapper function called SendEmailSimple.

Example usage of above code:

const char* Hostname = "axter_x.com";
const char* UserID = "axter_x";
const char* To = "maisonave@axter_x.com";
const char* Subject = "Your test is now complete";
const char* Body = "Auto-Notice: Your test is now complete";
SendEmailSimple(Hostname, UserID, To, Subject, Body);
0
 

Author Comment

by:mnoel76
ID: 12183487
jkr
checked out the codeproject.  where can I get the "stdafx.h" file that is included in the FastSmtp.cpp file
0
 

Author Comment

by:mnoel76
ID: 12183665
Axter
thanks for the code but it has to be win32.  we are not using MFC
0
 
LVL 30

Expert Comment

by:Axter
ID: 12184413
>>thanks for the code but it has to be win32.  we are not using MFC

Why do you think you need MFC?

It should be able to work on WIN32 application, with no MFC.

0
 
LVL 30

Expert Comment

by:Axter
ID: 12184437
>>where can I get the "stdafx.h" file that is included in the FastSmtp.cpp

It should aready be part of your project.

If not, then just commented it out.
You only need it if your file is setup to compile with precompile settings.
0
 
LVL 5

Expert Comment

by:danielsonchris
ID: 12186321
mnoel,
the stdafx.h is used for precompiled headers.  Didn't the exe come with that?  I didn't download it.. so I don't really know.  Windows uses precompiled headers in order to aid in speeding up re-compiling software that may be large.  Basically it caches your include libraries that are placed in the stdafx.h for you.
Good luck,
Chris
0
 

Author Comment

by:mnoel76
ID: 12190420
Axter - to answer your first question I had another person look at the error I am getting when I run execute it, cannot open file "nafxcwd.lib".  Anyway this person said told that this is because we are not using MFC and will not be.  Obviously this is in correct.  Axter can you steer on how to proceed from here.  
Danielsonchris - thanks for the input.
0
 
LVL 86

Expert Comment

by:jkr
ID: 12191897
Have you already tried http://support.microsoft.com/default.aspx?scid=kb;en-us;171096 ("FILE: Simple MAPI Console Application")?
0
 

Author Comment

by:mnoel76
ID: 12191997
jkr - i didn't have a chance to try it last night.  I should have some time tonight and will get back to you.  thanks
0
 
LVL 30

Expert Comment

by:Axter
ID: 12192325
>>Axter - to answer your first question I had another person look at the error I am getting when I run execute
>>it, cannot open file "nafxcwd.lib".  

This error does not have anything to do with the code I posted.

The error is related as to how the project is build, and what libraries are being included.

Check your build options, and make sure you don't have this library included.

I recommend you test the code I posted, by creating a new console application, or Win32 APP.
You'll see it uses no MFC.
0
 

Author Comment

by:mnoel76
ID: 12192887
Axter
I have created a new Win32 App. When I execute I get a 0x0048eb1b referenced memory of 0x00000000 memory could not be 'read'.  Why is this happening
Bye the way appreciate the continued help.
0
 

Author Comment

by:mnoel76
ID: 12193557
jkr and Axater - I have found some source code that works properly.  I appreciate both your input I am going to split the points based on your help.  Thanks again!!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question