Login  
Search All Forums
Dart Home | PowerTCP Mail for ActiveX | Custom Development Reply | PowerTCP Mail for ActiveX Topics | Forums   
AuthorForum: PowerTCP Mail for ActiveX
Topic: Sending messages with SMTP control in VC++
cjoyce

From: Apex, NC USA
Posts: 9
Member Since: 03/25/02
posted March 26, 2002 7:00 PM

Need a C++ app that will send both text & HTML messages. I'm starting with text messages and need some help. Do I create a new Message object and call the SMTP object's put_Message() method after setting it's properties or do I get the Message object from SMTP using get_Message(), set the properties and proceed? The same question could apply to the To property - create a new DartStrings object or just get the Message's existing one?

Here's a code snippet:
//Get the existing Message object
hr = m_pSMTPServer->get_Message(&pMessage);
//The sample did this, not sure it is necessary
pMessage->put_Content(msgMessage, msgString, _variant_t(""));
//Set the Subject and From properties
hr = pMessage->put_Subject(_bstr_t("Test Subject"));
hr = pMessage->put_From(_bstr_t("cjoyce@addressograph.com"));
//Get the DartStrings object that holds the To members
hr = pMessage->get_To(&pToList);
pToList->Add(_bstr_t("joe@company.com"), 0);
pToList->Add(_bstr_t("sally@company.com"), 1);

//Release the IDartStrings interface
pToList->Release();
pToList = NULL;
//Now call AddText to set the message text
IPart* pPart = NULL;
pMessage->AddText(_variant_t("This is the body of the email"), _bstr_t("us-ascii"), &pPart);
m_pSMTPServer->put_Timeout(60000);
_variant_t vLogTemp;
vLogTemp.SetString("c:\\temp\\Dart.log");
m_pSMTPServer->Trace(&vLogTemp, VARIANT_TRUE, VARIANT_TRUE, _bstr_t("\r\n---> "), _bstr_t("\r\n<--- "));
//Login to the SMTP server
hr = m_pSMTPServer->Login(_bstr_t("smtp.myserver.com"), 25, _bstr_t(""), _bstr_t(""));
_variant_t vTemp;
vTemp.ChangeType(VT_EMPTY, NULL);
//Send the message
hr = m_pSMTPServer->Send(&vTemp);
//Logout
hr = m_pSMTPServer->Logout();
I can send a message but it arrives with no subject or from address. It also only sends the mail to one recipient (sally). I've added two recipients. Where can I find step-by-step instruction on how to send text and html messages?
cjoyce

From: Apex, NC USA
Posts: 9
Member Since: 03/25/02
posted March 26, 2002 7:20 PM

Okay, I found something else that is very confusing. For brevity I left out one piece of code in my sample. I verify each address before adding it to the To collection. If You take my sample code as is, it works. If you replace these lines:

pToList->Add(_bstr_t("joe@company.com"), 0);
pToList->Add(_bstr_t("sally@company.com"), 1);

with this:

//Create a temp DartStrings obj to verify email addresses
IDartStrings * pDNS = NULL;
hr = ::CoCreateInstance(__uuidof(DartStrings), NULL, CLSCTX_ALL, __uuidof(IDartStrings), (void**)&pDNS);

//Add the DNS server to the list
hr = pDNS->Add(_bstr_t("my.dns.server"), 0);

//Verify each address before adding
VerifyMethodConstants result;
m_pSMTPServer->Verify(pDNS, _bstr_t("joe@company.com"), &result);
if (result == verifyValid )
{
pToList->Add(_bstr_t("joe@company.com"), 0);
}

m_pSMTPServer->Verify(pDNS, _bstr_t("sally@company.com"), &result);
if (result == verifyValid )
{
  pToList->Add(_bstr_t("sally@company.com"), 1);
}
pDNS->Release();
pDNS = NULL;

You get the results I indicated in my original post - an email only to the second recip. with no subject or from. Strange, huh?
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted March 28, 2002 5:18 PM


Hi Chris,
We have an article about HTML email here:
http://support.dart.com/KBDetail.dwp11
It is in VB, but it will help you to get started.
As far as using the control in VC++, I recommend looking at our samples. If you need help beyond this, please email us at support@dart.com.
Thanks,
-ken

K M Drake
Dart Tech Support
Reply | PowerTCP Mail for ActiveX Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX