发送没有Outlook的电子邮件

时间:2015-09-01 08:48:45

标签: vba email

Access可以轻松使用Outlook,但我的电脑没有Outlook。我可以用而不是另一种形式吗?我们公司只使用gmail,所以我需要在点击表格上的按钮后连接到Gmail。

我的按钮代码:

Private Sub Gmail_Click()

    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 = "something@domain.com"
     .Cc = "something@domain.com"
     .Subject = "Subject LIne"
     .HTMLBody = "<htmltags>Body Content</htmltags>"
     .send
    End With

    MsgBox "Operation completed successfully"

End Sub

1 个答案:

答案 0 :(得分:0)

我后来找到了答案解决方案。我只是创建一个带有超链接地址的标签,我们可以在其中设置文本到diplay,电子邮件地址,主题。因此,如果您单击此标签,它将导致标准邮件系统,如gmail。我希望这对其他人有帮助。

相关问题