简体   繁体   English

通过excel在线发送电子邮件

[英]Send email via excel online

I have two sheets. 我有两张床单。 One contain the complete information and other sheet contain certain information about one student which has to be emailed. 一个包含完整信息,另一个包含有关一个学生必须通过电子邮件发送的某些信息。 Please look at the screenshot below: 请看下面的截图:

第一个工作表

第二个工作表

Here, the second worksheet has student id field where I want to be able to write the row number and fill the below blank with the correct information from previous sheet automatically. 在这里,第二个工作表有学生ID字段,我希望能够写入行号,并自动填写下面的空白,并使用上一页中的正确信息。 And then I want to be able to send that worksheet as email. 然后我希望能够将该工作表作为电子邮件发送。 I only know basic of excel and I am using excel online. 我只知道excel的基础,我在网上使用excel。 Is there any way I could do it using excel online? 有什么方法可以使用excel在线吗? I have searched a lot but could not find any solution. 我搜索了很多但找不到任何解决方案。 Please help me out. 请帮帮我。 Thank you. 谢谢。

You can use a macro to send the email, and then trigger it with a shortkey, manually or add a button that calls it. 您可以使用宏来发送电子邮件,然后使用快捷键触发它,手动或添加一个调用它的按钮。 To create one, press Alt - F11 to open the Editor. 要创建一个,请按Alt - F11打开编辑器。 Click Insert -> Module, and add the following code: 单击插入 - >模块,然后添加以下代码:

Sub SendEmail()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String


Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

strbody = "Dear parent," & vbNewLine & vbNewLine & _
          "This is your child's report:" & vbNewLine
          Cells(1, 4).Value & " :" & Cells(2, 4).Value & vbNewLine
          Cells(1, 6).Value & " :" & Cells(2, 6).Value & vbNewLine
          Cells(1, 7).Value & " :" & Cells(2, 7).Value & vbNewLine
          Cells(1, 8).Value & " :" & Cells(2, 8).Value & vbNewLine
          Cells(1, 9).Value & " :" & Cells(2, 9).Value

On Error Resume Next
With OutMail
    .To = Cells(1,12).Value
    .CC = ""
    .BCC = ""
    .Subject = "Student Report"
    .Body = strbody
    .Send
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
End Sub

Whatever you put in strbody will be the body of the email. 无论你在strbody放置什么都将成为电子邮件的主体。 You can use the values of cells by using the Cells(columnnumber, rownumber).Value function. 您可以使用Cells(columnnumber, rownumber).Value函数来使用Cells(columnnumber, rownumber).Value的值。 You can look at this support page to see how to use a button, or at this page to run it manually or with a shortkey. 您可以查看此支持页面以了解如何使用按钮,或在此页面上手动或使用快捷键运行它。 Double check by sending it to yourself first, edit it to your taste. 先将它发送给自己,然后根据自己的喜好进行仔细检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM