Results 1 to 7 of 7

Thread: How to send mails from VC++ program rather than using outlook

  1. #1
    Join Date
    Jun 2011
    Posts
    55

    How to send mails from VC++ program rather than using outlook

    Hi I am studying the bachelor of science in information technology and we have to develop some projects through the programming language that we learn, and I have decided to make some application through which we can send the mails without using the outlook or through any other browser also, but I don’t know exactly which language do I use, and which would be better to use , as one of my friend was saying like we can do it by socket programming, isn’t it? Need suggestion would be appreciated.

  2. #2
    Join Date
    Mar 2010
    Posts
    2,578

    Re: How to send mails from VC++ program rather than using outlook

    I would suggest you that’s you should use only that languages in which you know all things perfectly, because as you have mentioned that you have decided to build program that sends mail, then let me tell you that if you use the VC++ then you must have to include some the library for using this, and if you are able to do that you should try to make it in this language only I have done the same. In fact you can use .NET framework also.

  3. #3
    Join Date
    May 2009
    Posts
    637

    Re: How to send mails from VC++ program rather than using outlook

    See I would like to suggest you that you should download some the library files from the internet that is used for sending the mails, and then use it with the VC++, and this is the best language among all for developing all such applications, and If you search it on the internet I would say there is whole documentation for reference programmer and from there you can refer some of the examples also for the same.

  4. #4
    Join Date
    May 2009
    Posts
    511

    Re: How to send mails from VC++ program rather than using outlook

    Hey seen I am mentioning the important part of the code that you have to insert, and some libraries that you have to insert on your own, and don’t worry that is too simple. Though this lines you can simply gives some authentication to your application.
    Code:
    Function MailMsg (const char *headline, const char *story, char *user id, char* WAU)
    	{
    		if ((NULL == headline) || (NULL == story) || (user id == NULL))
    			{
    				printf ("Unable to send the message due to error in msg.<br>\n");
    				return Failure;
    			}
    		FILE *mail;
    		char *email = NULL, *where;
    		if (NULL == (where = strchr (user id, '|')))
    {
    
    printf ("not able to discover bar delimiter in userid.<br>\n");
    				return Failure;
    			}
    		COPYSTRING (email, &(where[1]))
    		where[0] = '\0';
    		if (0 == strcmp ("Everyone", email))
    			return MailToEveryone (headline);
    		if (NULL != (mail = popen ("/usr/sbin/sendmail -t", "w")))
    			{
    				fprintf (mail, "To: %s <%s>\n", id, email);
    				fprintf (mail, "From: %s @ Message Board\n",WAU);
    				fprintf (mail, "Subject: %s\n", headline);
    				fprintf (mail, "\n");
    				fprintf (mail, "You have a message waiting\n");
    				fprintf (mail, "\n.\n");
    				pclose (mail);
    				return Success;
    			}
    		printf ("not able to begin sendmail.<br>\n");
    		return Failure;	
    	}

  5. #5
    Join Date
    May 2009
    Posts
    543

    Re: How to send mails from VC++ program rather than using outlook

    Well, if you are using VC++ for making this application than let me tell you that you need to have ATL classes for the same and for getting that you must have to have the paid version of the VC++, and along with that You’ll require the name of your email server as well. But I think you can get those files from internet also, and I think you should make the project in some other language because if you use this one, the coding will be too much.

  6. #6
    Join Date
    May 2009
    Posts
    529

    Re: How to send mails from VC++ program rather than using outlook

    Hey I have done it the same so you can follow up this program. You have to make some changes in the program I mean to say some of the path for library and the name of your Email server and all other small things. But in this program you must have to use the outlook, I know you have mentioned that you don’t want to use it, but still I without that you won’t be able to send emails.


    Code:
    // modify the path to msoutl85.olb if necessary.
       #import "C:\\Program Files\\MicrosoftOffice\\Office\\msoutl85.olb"\ 
       no_namespace exclude("_IRecipientControl", "_DRecipientControl")
    
       #include <stdio.h>
       #include <tchar.h>
    
       void dump_com_error(_com_error &e)
       {
        _tprintf(_T("Oops - hit an error!\n"));
        _tprintf(_T("\a\tCode = %08lx\n"), e.Error());
        _tprintf(_T("\a\tCode meaning = %s\n"), e.ErrorMessage());
        _bstr_t bstrSource(e.Source());
        _bstr_t bstrDescription(e.Description());
        _tprintf(_T("\a\tSource = %s\n"), (LPCTSTR) bstrSource);
        _tprintf(_T("\a\tDescription = %s\n"), (LPCTSTR) bstrDescription);
       }
    
     
       struct StartOle {
        StartOle() { CoInitialize(NULL); }
        ~StartOle() { CoUninitialize(); }
       } _inst_StartOle;
    
       void main()
       {
         try
        {
          NameSpacePtr pNameSpace;
          MAPIFolderPtr pOutbox;
          ItemsPtr pOutboxItems;
          _MailItemPtr PNMAIL;
          AttachmentsPtr pAttachments;
          RecipientsPtr pRecipients;
          RecipientPtr pRecipient;
       
                _ApplicationPtr pApp("Outlook.Application");
          pNameSpace = pApp->GetNamespace(L"MAPI");
          
          pOutbox = pNameSpace->GetDefaultFolder(olFolderOutbox);
                pOutboxItems = pOutbox->Items;
          PNMAIL = pOutboxItems->Add();
          PNMAIL->Subject = "Niche Mail Subject";
                PNMAIL->Body = "New mail body\n";
                pAttachments = PNMAIL->Attachments;
          pAttachments->Add("c:\\Autoexec.bat", (long)1, (long)(15000), 
                           "Autoexec.bat");
       
          pRecipients = PNMAIL->Recipients;
          pRecipients->Add("TO DO: Place email alias here");
          pRecipients ->ResolveAll();
    
          PNMAIL->Send();
          _tprintf(_T("Message sent\n"));
          pNameSpace->Logoff();
        }
    
         catch (_com_error &e)
         {
           dump_com_error(e);
         }
       }

  7. #7
    Join Date
    May 2009
    Posts
    527

    Re: How to send mails from VC++ program rather than using outlook

    I would like to suggest you that you should build the application in the ASP.Net as in that you will get a better platform and and visually also it will look great, and off course programming would be decrease as compare to other languages like as you have mentioned the one like VC++, and some other like java or C++. And here you just have to make the front end and some coding in the backend. You can see some of the examples on the internet that can help you.

Similar Threads

  1. cannot send mails on outlook 2003
    By genevievetully in forum Windows Software
    Replies: 2
    Last Post: 25-07-2011, 01:31 AM
  2. Unable to send reply to mails via Outlook in Windows Vista
    By Pikachoo in forum Technology & Internet
    Replies: 2
    Last Post: 20-02-2009, 11:01 PM
  3. How to send mails from Excel using Outlook
    By Elsie in forum Software Development
    Replies: 2
    Last Post: 08-12-2008, 03:24 PM
  4. I can't send mails in Outlook!!
    By Jose Banana in forum Windows Software
    Replies: 3
    Last Post: 08-08-2008, 11:39 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,095,543.87084 seconds with 17 queries