Solved

send email and attachment from another application written in C,  specifying SMPT server name and sender's email address

Posted on 2001-06-05
3
197 Views
Last Modified: 2008-03-03
What is the easiest way to send emails including attachments from within another application (written in C), specifying the SMPT Server Name and sender's email address (without using the default email client)? Is it possible to get some sample code in C?
0
Comment
Question by:birgitkelly
3 Comments
 
LVL 22

Expert Comment

by:ambience
ID: 6158465
hmmm ... that is a whole lot of work , the easiest way is to use classes that others have built for this purpose or equivalently C code if you find somewhere , there are some good C++ sources on codeguru and codeproject .. I haven't seen any pure C thing as such .. but i guess you can get the idea and do it in C as well.

The other way is to write your own code for talking to SMTP servers , see the RFC on SMTP for more info about the protocol.
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 70 total points
ID: 6158517
Easiest way to send EMail: use tapi
see Simple MAPI Console Application
http://support.microsoft.com/support/kb/articles/q171/0/96.asp
Standart way: use sockets. As examples see
  Send mail with Sockets
  www.xmailserver.com/davide.html

Use JMail component:
  You can use JMail component to send and receive mails.  Its a very cool component and you can download
it free from http:\\dimac.net

See the following code to send mail

#include <windows.h>
#include <stdio.h>
#include <conio.h>

#import "path where you have your jmail.dll is installed \jmail.dll" no_namespace

int main()
{
    CLSID clsid;
    ISMTPMailPtr smtpptr;
   
    if (FAILED(::CoInitialize(NULL))) return 0;
    ::CLSIDFromProgID(L"jmail.SMTPMail",&clsid);
   
    if (FAILED(smtpptr.CreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER)))
    {
         printf("Failed to Create Instance");
         getch();
    }

    smtpptr->ServerPort = 8000;
    smtpptr->ServerAddress = "192.168.20.1";
    smtpptr->AddRecipient(_bstr_t("tparavind@yahoo.com"));
    smtpptr->Subject = "Hai";
    smtpptr->Body = "This is the test mail using Jmail Component";
    smtpptr->SenderName = "Thirumalaiappan";
    smtpptr->Execute();

    return 0;
}
 
I hope, you chouse one of this ways.
Alex
0
 

Author Comment

by:birgitkelly
ID: 6178888
Sorry it took soo long to reply. I have checked out all the links in your email. They were all very good. I have decided to send emails with sockets (http://www.xmailserver.com/davide.html). I have downloaded SndMail 1.8 which works wonderful. It allows for email to be sent from the command prompt or via use of the dll. And best of all, the source code is included. Thank you very much for your help.
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual c++ and text files 7 67
java inner class, for the sole use of parameter passing 21 77
how to understand recursion 12 226
How can i compile this github project?? 2 83
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

770 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