当尝试运行特定过程并满足某些条件时,我尝试从MS Access生成电子邮件,该电子邮件将包含超链接。我发现sendobject宏命令不允许超链接,仅允许静态文本。似乎解决方案是对整个过程的一部分进行编码,该过程在VBA中生成和发送电子邮件,然后在宏中if函数的相应段中调用该代码。
我无法找出合适的代码来生成,发送和发送带有超链接的电子邮件给个人。这将是非常简单,单一的,不变的标题,并且正文将显示为“新的提供商需要指定,请访问提供商指定仪表板以进行提供商指定”。理想情况下,提供商指定仪表板将是超链接并指向共享的网络空间。
我需要什么命令来完成此操作,我对VBA经验不足,这正在吞噬我没有的大量时间。
谢谢
有几种发送带有代码的电子邮件的方法。下面的代码使用Outlook Application COM对象生成带有超链接的消息-因此,仅当在用户计算机中安装了MS Outlook时,该代码才起作用。
Sub NewEmail(ByVal mylink As String, ByVal therecipient As String)
Dim Outlook As Object, Email As Object
Set Outlook = CreateObject("Outlook.Application")
Set Email = Outlook.CreateItem(0) 'olMailItem = 0
With Email
.Subject = "My Subject" 'message subject
.HTMLBody = "Greetings, please check this link: <a href='" & mylink & "'>Click me</a>." 'message body, in html. concatenate multiple strings if you need to
.To = therecipient 'recipient
'use this if you want to generate the message and show it to the user
.Display
'use this instead if you want the mail to be sent directly
'.Send
End With
Set Email = Nothing
Set Outlook = Nothing
End Sub
将代码放入模块中。然后,您可以在代码中的任何位置调用该过程,例如:
NewEmail "www.mysite.com/targetpage.html", "[email protected]"
注意上面的例程使用了后期绑定。要使用早期绑定(并获得智能化,但有一些缺点),您必须添加对Microsoft Outlook XX.X对象库的引用,并将“ Outlook”和“ Email”对象的颜色设置为Outlook.Application和Outlook.MailItem,分别。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句