0

如何从 MS Access Form 发送邮件。?

假设我有带有仪表板表单的 MS Access 应用程序。我已将邮件发送到某些邮件地址,例如在单击“发送通知按钮”时发送通知邮件 如何在 MS 访问中使用 codebuilder 执行此操作

4

2 回答 2

2

我发现您可以使用此代码段发送邮件

Private Sub send_mail()

   Dim olApp As Object
   Dim objMail As Object

   On Error Resume Next 'Keep going if there is an error
   Set olApp = GetObject(, "Outlook.Application") 'See if Outlook is open

    If Err Then 'Outlook is not open
       Set olApp = CreateObject("Outlook.Application") 'Create a new instance 
    End If
  'Create e-mail item
   Set objMail = olApp.CreateItem(olMailItem)

   With objMail
   'Set body format to HTML
     .BodyFormat = olFormatHTML
     .To = "abc@yourmailaddress.com"
     .Cc ="ccaddress@yourmailaddress.com"
     .Subject = "Subject LIne"
     .HTMLBody = "<htmltags>Body Content</htmltags>"
     .send
   End With

  MsgBox "Operation completed successfully"

 End Sub

来源:来自 Access Programmer 站点的线程

于 2012-10-05T07:29:42.070 回答
0

我发现了一些基于我用来从联系人主页打开浏览器的代码的电子邮件代码,工作得很好,而且对我来说更容易理解。要打开网页,请删除 '"mailto:" & '。

Private Sub cmdEmailContact_Click()
Dim sWebPath As String
Dim sFullLinkPath As String

If IsNull(Me.ContactEmail) Then
    MsgBox ("Can't create email: no address listed")
    Exit Sub
End If

sWebPath = "mailto:" & Me.ContactEmail

sFullLinkPath = sWebPath
Application.FollowHyperlink sFullLinkPath

End Sub
于 2014-12-01T16:59:49.003 回答