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

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

问题描述

我是 VC++ 和编程的新手.

I am new to VC++ and programming.

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

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

我该怎么做?请帮忙!!

推荐答案

以下是我使用 ATL 类的方法.我认为您需要 VC++ 的付费版本之一才能获得 ATL.您将需要电子邮件服务器的名称.

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天全站免登陆