如何发送电子邮件在VC ++? [英] How to send a email in VC++?

查看:198
本文介绍了如何发送电子邮件在VC ++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很喜欢VC ++和编程。



我必须编写代码才能在VC ++中发送电子邮件。



我该怎么做?请帮助!!

解决方案

这是我如何使用ATL类。我想你需要一个付费版本的VC ++才能获得ATL。您将需要您的电子邮件服务器的名称。

  CSMTPConnection smtp; 
if(!smtp.Connect(m_strEmailServer))
return false;
//开始生成电子邮件;记得在这个
CMimeMessage msg之前在应用程序的某个地方调用CoInitialize;
msg.SetSubject(m_strSubject);
msg.SetSender(m_strSender);
//根据需要重复以下操作
msg.AddRecipient(strSingleRecipient);
msg.AddText(m_strBody);
if(!smtp.SendMessage(msg))
return false;
返回true;


I am new to VC++ and programming.

I have to write code to send a email in VC++.

How do I go about it? Please help!!

解决方案

Here's how I do it with the ATL classes. I think you need one of the paid versions of VC++ to get ATL. You will need the name of your email server.

CSMTPConnection smtp;
if (!smtp.Connect(m_strEmailServer))
    return false;
// start generating the email message; remember to call CoInitialize somewhere in the app before this
CMimeMessage msg;
msg.SetSubject(m_strSubject);
msg.SetSender(m_strSender);
// repeat the following as necessary
msg.AddRecipient(strSingleRecipient);
msg.AddText(m_strBody);
if (!smtp.SendMessage(msg))
    return false;
return true;

这篇关于如何发送电子邮件在VC ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆