• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

Need code to send email once test is complete

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
mnoel76
Asked:
mnoel76
  • 7
  • 4
  • 4
  • +1
2 Solutions
 
jkrCommented:
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
 
jkrCommented:
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
 
mnoel76Author Commented:
jkr

I will check into tonight as I can not download .exe at work.  I working on windows by the way.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
jkrCommented:
The CodeProject file is a zipped archive, if you can download that...
0
 
AxterCommented:
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
 
mnoel76Author Commented:
jkr
checked out the codeproject.  where can I get the "stdafx.h" file that is included in the FastSmtp.cpp file
0
 
mnoel76Author Commented:
Axter
thanks for the code but it has to be win32.  we are not using MFC
0
 
AxterCommented:
>>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
 
AxterCommented:
>>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
 
danielsonchrisCommented:
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
 
mnoel76Author Commented:
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
 
jkrCommented:
Have you already tried http://support.microsoft.com/default.aspx?scid=kb;en-us;171096 ("FILE: Simple MAPI Console Application")?
0
 
mnoel76Author Commented:
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
 
AxterCommented:
>>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
 
mnoel76Author Commented:
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
 
mnoel76Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 4
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now