How to send a email in VC++?

前端 未结 2 421
野的像风
野的像风 2021-01-06 11:47

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!!

2条回答
  •  执笔经年
    2021-01-06 12:04

    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;
    

提交回复
热议问题