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

查看:234
本文介绍了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)发送电子邮件,而不是在出现安全提示后从用户的外表地址发送电子邮件.如果无法做到这一点,那么我可以接受其他解决方法的想法.

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包含一个名为协作数据对象"或CDO的对象.该对象允许您在满足其他先决条件(防火墙打开,ISP不阻止端口,在SMTP服务器上配置帐户,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的测试中,如果您希望使用早期绑定,则正确的库引用似乎是用于Windows 2000库的Microsoft CDO".

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