Vb.net 电子邮件终端快捷方式
我需要为类更改此VBA代码。我正在看本教程,我想直接从excel使用Apple Mail stmp[“mailto:”]函数,而不是Outlook。我已经记下了主题和消息部分,但我想知道的是,如果我们正确保存它,我是否可以直接从终端运行这个脚本?同时,你也可以说明我需要在哪里对我的电子邮件进行具体更改Vb.net 电子邮件终端快捷方式,vb.net,excel,vba,Vb.net,Excel,Vba,我需要为类更改此VBA代码。我正在看本教程,我想直接从excel使用Apple Mail stmp[“mailto:”]函数,而不是Outlook。我已经记下了主题和消息部分,但我想知道的是,如果我们正确保存它,我是否可以直接从终端运行这个脚本?同时,你也可以说明我需要在哪里对我的电子邮件进行具体更改 Private Declare Function ShellExecute Lib "shell32.dll" _ Alias "ShellExecuteA" (ByVal hwnd As Lon
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Sub SendEMail()
Dim Email As String, Subj As String
Dim Msg As String, URL As String
Dim r As Integer, x As Double
For r = 2 To 4 'data in rows 2-4
' Get the email address
Email = Cells(r, 2)
' Message subject
Subj = "Your Annual Bonus"
' Compose the message
Msg = ""
Msg = Msg & "Dear " & Cells(r, 1) & "," & vbCrLf & vbCrLf
Msg = Msg & "I am pleased to inform you that your annual bonus is "
Msg = Msg & Cells(r, 3).Text & "." & vbCrLf & vbCrLf
Msg = Msg & "William Rose" & vbCrLf
Msg = Msg & "President"
' Replace spaces with %20 (hex)
Subj = Application.WorksheetFunction.Substitute(Subj, " ", "%20")
Msg = Application.WorksheetFunction.Substitute(Msg, " ", "%20")
' Replace carriage returns with %0D%0A (hex)
Msg = Application.WorksheetFunction.Substitute(Msg, vbCrLf, "%0D%0A")
' Create the URL
URL = "mailto:" & Email & "?subject=" & Subj & "&body=" & Msg
' Execute the URL (start the email client)
ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus
' Wait two seconds before sending keystrokes
Application.Wait (Now + TimeValue("0:00:02"))
Application.SendKeys "%s"
Next r
End Sub
在Windows中,可以将VBA应用程序另存为.vbs文件,然后从命令提示符或Windows资源管理器中运行。如果您有Excel特定的函数,或者如果VB版本不相同,则可能会出现错误,但通常它会运行。我应该指出,StackOverflow不是让人们为您做作业的地方……也是VBA VB.NET