Solved

Email Problem

Posted on 2004-09-23
11
222 Views
Last Modified: 2011-04-14
I'm new - really new-idiot level- at programming and trying understand and use the SendEmail.cpp from Axter.  I used the example SendEmail Simple function to send an email to myself and it worked great.  Now, I've been trying to modify and use the program to read addresses from a text file and send mail to these addresses using the BCC field. I've tried the examples but can't make them to work - don't know how.  Can someone please help me?  Thanks.  
0
Comment
Question by:jazamor
  • 7
  • 4
11 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 12138002
>>I've tried the examples but can't make them to work - don't know how.  Can someone
>>please help me?  Thanks.  

Can you post your code.
Exactly how did it not work?   Did it fail to compile, fail to run, fail to send email, fail to send attachement with email......????

Give us as much details as you can.
0
 
LVL 30

Expert Comment

by:Axter
ID: 12138049
Example:

const char* Hostname = "axter_x.com";
const char* UserID = "axter_x";
const char* To = "maisonave@axter_x.com";
const char* Subject = "This is a test email";
const char* Body = "Test body";
const char* UserPassword = "abc123";

const char* AttachedFile = "C:\\autoexec.bat";

SendEmailSimple(Hostname, UserID, To, Subject, Body, UserPassword, AttachedFile);
0
 
LVL 30

Expert Comment

by:Axter
ID: 12138066
If you're using a string literal for your attached file, make sure that it has double \ characters

"c:\\windows\\system32\\somefile.txt"
0
 
LVL 30

Expert Comment

by:Axter
ID: 12138089
Where did you get the SendEmail.cpp file from.
Was it from a link to my web site, or was it a copy and paste on another question?
0
 

Author Comment

by:jazamor
ID: 12138161
I'm sorry it's taken me so long to answer.  The code I used is yours exactly the way you have it.  I put in this from your examples

int main(int , char*)
      {
            const char* Hostname = "mailgate.sandia.gov";
            const char* UserID = "entrustt@sandia.gov";
            const char* To = "jazamor@sandia.gov";
            const char* Subject = "This is a test email";
            const char* Body = "Test body";
            SendEmailSimple(Hostname, UserID, To, Subject, Body);
            return 0;
      }      

const char CCListTest[][64] = {"jazamor@sandia.gov","jazamor@sandia.gov","jazamor@sandia.gov"};

const char BCCListTest[][64] = {"jazamor@sandia.gov","jazamor@sandia.gov","jazamor@sandia.gov"};

void ExampleFunctionToSendMailToMultipleToCC_AndBCC(const std::string &Hostname, const std::string &UserID, const std::string &UserPassword)
{//Example for Multiple TO fields CC and BCC field
      std::list<std::string> ToList;
      ToList.push_back(ToListTest[0]);
      ToList.push_back(ToListTest[1]);
      ToList.push_back(ToListTest[2]);
      std::list<std::string> CCList;
      CCList.push_back(CCListTest[0]);
      CCList.push_back(CCListTest[1]);
      CCList.push_back(CCListTest[2]);
      std::list<std::string> BCCList;
      BCCList.push_back(BCCListTest[0]);
      BCCList.push_back(BCCListTest[1]);
      BCCList.push_back(BCCListTest[2]);
      std::string Results = SendEmail(Hostname, UserID, UserPassword)(
            ToList,
            "*File Test x15x: Please ignore this email.",
            "Test from SendEmail.  Please ignore this email.",
            &CCList,
            &BCCList);
      if (Results != SendEmail::NO_ERRORS)
      {
            printf("Error:\r\n");
            printf(Results.c_str());
            printf("\r\n\r\nPress ENTER to quit\r\n");
            getchar();
      }
}

These are the errors I get.  My main problem is I don't understand what I'm doing.

Compiling...
SendEmail.cpp
C:\Documents and Settings\jazamor\Desktop\SendEMail\SendEmail.cpp(556) : error C2065: 'ToListTest' : undeclared identifier
C:\Documents and Settings\jazamor\Desktop\SendEMail\SendEmail.cpp(556) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\jazamor\Desktop\SendEMail\SendEmail.cpp(556) : error C2664: 'push_back' : cannot convert parameter 1 from 'int' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &'
        Reason: cannot convert from 'int' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
        No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Documents and Settings\jazamor\Desktop\SendEMail\SendEmail.cpp(557) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\jazamor\Desktop\SendEMail\SendEmail.cpp(557) : error C2664: 'push_back' : cannot convert parameter 1 from 'int' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &'
        Reason: cannot convert from 'int' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
        No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Documents and Settings\jazamor\Desktop\SendEMail\SendEmail.cpp(558) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\jazamor\Desktop\SendEMail\SendEmail.cpp(558) : error C2664: 'push_back' : cannot convert parameter 1 from 'int' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &'
        Reason: cannot convert from 'int' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
        No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.

SendEmail.obj - 7 error(s), 0 warning(s)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:jazamor
ID: 12138179
I believe I downloaded it from your web site.
0
 
LVL 30

Accepted Solution

by:
Axter earned 500 total points
ID: 12138325
It looks like you have modified the original SendEmail.cpp file.

The version posted on the web only has commented code with the keyword ToListTest

Also, line 556 on the posted version has the following:
      if (uc  < 26) return 'A'+uc;


Try downloading the file again, and use it without modifying it.
http://www.axter.com/code/SendEmail.cpp
http://www.axter.com/code/SendEmail.h

When you use SendEmail.cpp and SendEmail.h, you should be able to use them both without modifying the files.

You should call the functions or class from your code which should be in a different file.
Like:
main.cpp
or
myprogram.cpp

In your *.cpp file, add your main() function, and call the function from there.
0
 

Author Comment

by:jazamor
ID: 12138402
Okay, If I understand what your saying.  I can use your example for multiple CC and BCC field, at the end of the SendEmail.cpp as is and call it from a main() function in myown.cpp ?
0
 
LVL 30

Expert Comment

by:Axter
ID: 12139502
>>SendEmail.cpp as is and call it from a main() function in myown.cpp ?

That's correct.
0
 

Author Comment

by:jazamor
ID: 12143414
Okay, I'll give it a try. Since I new at this would it be okay to accept your answer for now and then post another question to you later if I have problems.  Thanks for your help.
0
 
LVL 30

Expert Comment

by:Axter
ID: 12144074
>>Thanks for your help.

Your welcome.

If you have any questions, or suggestions, feel free to posted here.

I have change this class before when I've received good suggestions for generic modification of the class.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maze travler 6 51
Dynamically allocate memory 9 56
Embarcadero WebBroker REST server endpoint parameters 2 52
Installshield for Embarcadero EX 10.1 Berlin 4 14
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

930 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now