在Exchange环境中从Excel发送电子邮件 [英] Send email from Excel in Exchange environment

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

问题描述

我有一个用户表格,可帮助不同的用户将数据填入电子表格。一旦数据被插入,它也应该通过电子邮件发送给几个收件人,具体取决于表单中填写的选项。

I have a userform that helps different users fill in data into the spreadsheet. As soon as the data is inserted it should also be sent by email to a few recipients, depending on the options filled in the form.

这种情况发生在企业环境中交换。我将为此文件创建一个新的电子邮件帐户,以便能够作为实体发送电子邮件,而不使用用户的电子邮件帐户。

This happens within a corporate environment using Exchange. I would create a new email account for this file to be able to send the email as an entity and not use the user's email account.

这可能吗?怎么样?我已经google了,我可以找到的是如何创建用户从他的帐户发送的邮件。

Is this possible? How? I have googled for it and all I can find is how to create a mail message that the user sends from his account.

推荐答案

我使用了以下代码( )从Excel-VBA发送电子邮件。我只使用自己的电子邮件帐户进行测试,但我认为您可以从其他帐户发送邮件( msgOne.from = ... ),只要用户有权限在Exchange服务器上从该帐户发送。

I've used the code below (source) to send e-mails from Excel-VBA. I've only tested it with my own e-mail account, but I assume you could have it send mail from a different account (msgOne.from = ...), as long as the user has permission to send from that account on the Exchange server.

Dim cdoConfig
Dim msgOne

Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
    .Item(cdoSendUsingMethod) = cdoSendUsingPort
    .Item(cdoSMTPServerPort) = 25 '465 ' (your port number) usually is 25
    .Item(cdoSMTPServer) = "smtp.mysmtpserver.com" ' your SMTP server goes here
    '.Item(cdoSendUserName) = "My Username"
    '.Item(cdoSendPassword) = "myPassword"
    .Update
End With

Set msgOne = CreateObject("CDO.Message")
Set msgOne.Configuration = cdoConfig
msgOne.To = "someone@somewhere.com"
msgOne.from = "me@here.com"
msgOne.subject = "Test CDO"
msgOne.TextBody = "It works just fine."
msgOne.Send

不幸的是,我不能在这个时候测试这个假设,因为我只设置从一个帐户发送。让我知道它是如何工作的!

Unfortunately, I can't test this hypothesis at this time, as I'm only set up to send from one account. Let me know how it works out!

这篇关于在Exchange环境中从Excel发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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