How do I add a subject header to my SMTP application?

Article ID: 1049
Last updated: 02 Feb, 2008
Article ID: 1049
Last updated: 02 Feb, 2008
Revision: 1
Views: 24978
Posted: 02 Oct, 1998
by Dean J.
Updated: 02 Feb, 2008
by Dean J.
Problem


How do I add a subject header to my SMTP application using Rogue Wave's RWISmtpAgent or RWISmtpClient classes?


Cause


According to the RFC 821 for SMTP, the mail data or message body includes the memo header items such as Date, Subject, To, Cc and From. For example if you want to include a Subject header to your application, then you need to add explicitly the Subject memo header item to the message body as follows:


RWSocketPortal portal = agent.send(From,To);
portal.sendAtLeast(Subject: Hello );
portal.sendAtLeast(Here goes the message );


Now Hello is shown as the subject header in your email.


Action


#pragma warning( disable : 4251 )

#include
#include
#include
#include
#include
#include

int main(){
RWWinSockInfo info;

try {
// Construct an agent to talk with our known SMTP server
RWISmtpAgent agent(wipeout.cvo.roguewave.com);

// Force the RWIOUResult to redeem
// immediately for our portal.
RWSocketPortal portal = agent.send(ravi@roguewave.com, inampudi@roguewave.com);

// Send our one line message, on the way out.
portal.sendAtLeast(Subject: Hello );
portal.sendAtLeast(I've gone to the beach. om. );

// Close up the agent and go to the beach
// Force the RWIOUResult to
// redeem immediately for the result.
RWBoolean result = agent.dataClose();
}
catch (const RWxmsg& m) {
cout << Error : << m.why() << endl;
}

return 0;
}

 


This article was:   Helpful | Not helpful
Report an issue
Article ID: 1049
Last updated: 02 Feb, 2008
Revision: 1
Views: 24978
Posted: 02 Oct, 1998 by Dean J.
Updated: 02 Feb, 2008 by Dean J.

Others in this category