MS Access 发送电子邮件(不是来自 Outlook 或用户的电子邮件) [英] MS Access send email (not from outlook or user's email)

查看:40
本文介绍了MS Access 发送电子邮件(不是来自 Outlook 或用户的电子邮件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题在不同的背景下被问过几次,但我没有找到明确的答案.我已经使用 Outlook 为访问应用程序实现了电子邮件,但我想摆脱这一点.电子邮件的目的之一是在用户忘记密码时通过电子邮件将其/或密码发送给用户.他们可以为登录屏幕选择用户名,如果他们点击忘记密码",则会发送包含登录信息的电子邮件(发送到与用户名关联的电子邮件地址).

I know this question has been asked a few times in various context, but I have not found a clear answer. I have email implemented for an access application using outlook, but I'd like to move away from this. One of the purposes of the email is to email a user his/or password if he forgot it. They can select their username for the login screen, and if they click 'forgot password' and email is sent containing their login information (to the email address associated with the user name).

这样做的问题是电子邮件功能从用户的机器发送了一封带有 Outlook 的电子邮件.因此,用户将能够忘记密码"其他用户名并查看自己的 Outlook 发件箱(已发送邮件)以查看敏感信息.

The problem with this is that the email function as is sends an email with outlook from the user's machine. So, users would be able to 'forgot password' other usernames and view their own outlook outbox(sent items) to see the sensitive information.

有没有办法像php的邮件功能一样发邮件,从服务器发送邮件?我希望电子邮件从相同的电子邮件地址发送,即 (support@company.com),而不是在安全提示后从用户的 Outlook 地址发送.如果这是不可能的,我愿意接受任何其他解决方法的想法.

Is there a way to e-mail like php's mail function, sending mail from the server? I would like the emails to be sent from the same email address i.e(support@company.com), instead of from the user's outlook address after a security prompt. If this is not possible, I am open to the idea of any other workarounds.

我还要补充一点,安装任何必须安装在每个潜在用户的机器上的软件都是不可行的.

I will also add that installing any software that would have to be installed on every potential user's machine is not feasible.

这可能吗?

推荐答案

Windows 包括一个名为 Collaborative Data Objects 或 CDO 的对象.此对象允许您使用任何 SMTP 服务器发送电子邮件,前提是满足其他先决条件(防火墙打开、ISP 未阻止端口、在 SMTP 服务器上配置帐户、SMTP 服务器允许中继等).

Windows includes an object called Collaborative Data Objects or CDO. This object allows you to send emails using any SMTP server assuming that other prerequisites are met (firewall open, ISP not blocking ports, account is configured on the SMTP server, SMTP server allows relaying, etc).

我发现的大多数示例都使用后期绑定,这是首选.在我对 XP 的测试中,如果您更喜欢使用早期绑定,那么正确的库参考似乎是Microsoft CDO for Windows 2000 库".

Most of the examples I've found use late binding, which is preferred. In my testing on XP it appeared that the correct library reference, if you prefer to use early binding, is "Microsoft CDO for Windows 2000 Library".

重要的是要知道,无论何时发送电子邮件,都必须通过(或从)某种电子邮件服务器发送.这意味着您必须通过该电子邮件服务器进行身份验证,而且通常还意味着您需要使用该电子邮件服务器上存在的发件人"电子邮件地址发送电子邮件.

It's important to know that any time you send email you will have to send it through (or out of) some kind of email server. This means you will have to authenticate with that email server and also usually means that you need to send the email out using a "From" email address that exists on that very email server.

这是一些使用后期绑定的代码:

Here's some code using late binding:

Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2
Const cdoAnonymous = 0
' Use basic (clear-text) authentication.
Const cdoBasic = 1
' Use NTLM authentication
Const cdoNTLM = 2 'NTLM

Public Sub SendEmail()
    Dim imsg As Object
    Dim iconf As Object
    Dim flds As Object
    Dim schema As String

    Set imsg = CreateObject("CDO.Message")
    Set iconf = CreateObject("CDO.Configuration")
    Set flds = iconf.Fields

    ' send one copy with SMTP server (with autentication)
    schema = "http://schemas.microsoft.com/cdo/configuration/"
    flds.Item(schema & "sendusing") = cdoSendUsingPort
    flds.Item(schema & "smtpserver") = "mail.myserver.com"
    flds.Item(schema & "smtpserverport") = 25
    flds.Item(schema & "smtpauthenticate") = cdoBasic
    flds.Item(schema & "sendusername") = "email@email.com"
    flds.Item(schema & "sendpassword") = "password"
    flds.Item(schema & "smtpusessl") = False
    flds.Update

    With imsg
        .To = "email@email.com"
        .From = "email@email.com"
        .Subject = "Test Send"
        .HTMLBody = "Test"
        '.Sender = "Sender"
        '.Organization = "My Company"
        '.ReplyTo = "address@mycompany.com"
        Set .Configuration = iconf
        .Send
    End With

    Set iconf = Nothing
    Set imsg = Nothing
    Set flds = Nothing
End Sub

这篇关于MS Access 发送电子邮件(不是来自 Outlook 或用户的电子邮件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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