Note: The other languages of the website are Google-translated. Back to English
登入  \/ 
x
or
x
註冊  \/ 
x

or

如何在復制和粘貼指定範圍到Excel中的電子郵件正文中發送電子郵件?

在許多情況下,Excel工作表中指定範圍的內容可能對您的電子郵件通信很有用。 在本文中,我們將介紹一種直接在Excel中發送將具有指定範圍的電子郵件粘貼到電子郵件正文中的方法。

發送具有指定範圍的電子郵件,粘貼到Excel中的電子郵件正文中
使用出色的工具發送指定範圍的電子郵件,並將其粘貼到電子郵件正文中

有關在Excel中發送郵件的更多教程...


發送具有指定範圍的電子郵件,粘貼到Excel中的電子郵件正文中

以下VBA代碼可以幫助您複製範圍並將其直接粘貼到Excel中的Outlook電子郵件正文中。 請執行以下操作。

1.在工作表中包含您需要復制的範圍,按 其他 + F11 同時打開 Microsoft Visual Basic for Applications 窗口。

2.在開幕 Microsoft Visual Basic for Applications 窗口,請點擊 工具 > 參考 如下圖所示。

3。 在裡面 參考– VBAProject 對話框,請查找並檢查 Microsoft Outlook對像庫 選項,然後單擊 OK 按鈕。

4。 點擊 插入 > 模塊,然後將下面的VBA代碼複製並粘貼到“模塊”窗口中。

VBA代碼:發送具有指定範圍的電子郵件,粘貼到Excel中的電子郵件正文中

Sub Send_Email()
'Updated by Extendoffice 20200119
    Dim xRg As Range
    Dim I, J As Long
    Dim xAddress As String
    Dim xEmailBody As String
    Dim xMailOut As Outlook.MailItem
    Dim xOutApp As Outlook.Application    
    On Error Resume Next
    xAddress = ActiveWindow.RangeSelection.Address
    Set xRg = Application.InputBox("Please select range you need to paste into email body", "KuTools For Excel", xAddress, , , , , 8)
If xRg Is Nothing Then Exit Sub
Application.ScreenUpdating = False
    Set xOutApp = CreateObject("Outlook.Application")
    Set xMailOut = xOutApp.CreateItem(olMailItem)
    For I = 1 To xRg.Rows.Count
        For J = 1 To xRg.Columns.Count
            xEmailBody = xEmailBody & "  " & xRg.Cells(I, J).value
        Next
        xEmailBody = xEmailBody & vbNewLine
    Next
    xEmailBody = "Hi" & vbLf & vbLf & " body of message you want to add" & vbLf & vbLf & xEmailBody & vbNewLine
    With xMailOut
        .Subject = "Test"
        .To = "happy.xuebi@163.com"
        .Body = xEmailBody
        .Display
        '.Send
    End With
    Set xMailOut = Nothing
    Set xOutApp = Nothing
    Application.ScreenUpdating = True
End Sub

筆記:

  • 1)。 請更改電子郵件正文 xEmailBody =“嗨”&vbLf&vbLf&“您要添加的郵件正文”&vbLf&vbLf&xEmailBody&vbNewLine 如你所需。
  • 2)。 請指定您的電子郵件收件人和主題(至= happy.xuebi@163.com.Subject =“測試”) 代碼中的行。

5。 按 F5 鍵來運行代碼。 在彈出 Kutools for Excel 對話框,請選擇您需要粘貼到電子郵件正文中的範圍,然後單擊 OK 按鈕。 看截圖:

6.現在,將創建一封包含指定收件人,主題,正文和所選Excel範圍的電子郵件,請單擊 發送 按鈕發送此電子郵件。 請參閱顯示的屏幕截圖。

備註:僅當您將Outlook用作電子郵件程序時,VBA代碼才起作用。


使用出色的工具發送指定範圍的電子郵件,並將其粘貼到電子郵件正文中

如果您不使用Outlook,但仍希望直接在Excel中直接發送電子郵件,並在其中粘貼指定的範圍數據,則強烈建議您使用 發電子郵件 的效用 Kutools for Excel 為了你。 使用此功能,您只需要配置電子郵件地址的傳出服務器,然後以後再通過此電子郵件地址直接在Excel中發送電子郵件。

申請前 Kutools for Excel首先下載並安裝.

1.首先,您需要準備一個帶有必填字段的郵件列表。

  • 保養竅門:郵件列表必須至少包含2行,並且第一行必須為標頭(假設您要將電子郵件發送到Excel中的兩個電子郵件地址,請輸入這兩個電子郵件地址,標頭為“ Email”,如下所示) )。
  • 或者,您可以使用以下命令輕鬆創建郵件列表 創建郵件列表 功能。

2.選擇範圍,將數據添加到電子郵件正文,然後按 按Ctrl + C 鍵複製它。

3.選擇整個郵件列表(包括標題),單擊 Kutools Plus > 發電子郵件。 看截圖:

4.然後 發電子郵件 對話框彈出。

  • 4.1)所選郵件列表的項目填充在相應的字段中(您可以根據需要在郵件列表中添加更多字段);
  • 4.2)點擊電子郵件正文框,然後按 按Ctrl + V 鍵將選定的範圍數據粘貼到其中。 之後,根據需要添加其他內容;
  • 4.3取消選中 通過Outlook發送電子郵件 框;
  • 2.4)點擊 發送服務器設置 按鈕。 看截圖:

5.然後 傳出服務器(SMTP)設置-新方案 對話框彈出。 請在電子郵件地址中填入其服務器設置,並在選中以下內容後指定一個文件夾來保存所有已發送的郵件 將發送的電子郵件保存到 框,然後單擊 OK 按鈕保存設置。

6.返回到 發電子郵件 對話框中,單擊 發送 按鈕發送電子郵件。

從現在開始,您可以直接在Excel中發送具有此功能的電子郵件。

  如果您想免費試用該工具(30天), 請點擊下載,然後按照上述步驟進行操作。


相關文章:

將電子郵件發送到Excel單元格中指定的電子郵件地址
假設您有一個電子郵件地址列表,並且您想直接在Excel中批量向這些電子郵件地址發送電子郵件。 如何實現呢? 本文將向您展示將電子郵件發送到Excel中單元格中指定的多個電子郵件地址的方法。

在Excel中發送電子郵件時插入Outlook簽名
假設要直接在Excel中發送電子郵件,如何在電子郵件中添加默認的Outlook簽名? 本文提供了兩種方法來幫助您在Excel中發送電子郵件時添加Outlook簽名。

發送帶有Excel中附加的多個附件的電子郵件
本文討論的是通過帶有Excel中附加的多個附件的Outlook發送電子郵件。

如果在Excel中已達到到期日期,則發送電子郵件
例如,如果C列中的截止日期小於或等於7天(當前日期為2017/9/13),則向A列中的指定收件人發送電子郵件提醒,並在B列中指定內容。實現這一目標? 本文將提供一種VBA方法來詳細處理它。

根據Excel中的單元格值自動發送電子郵件
假設您要基於Excel中指定的單元格值通過Outlook向特定收件人發送電子郵件。 例如,當工作表中單元格D7的值大於200時,將自動創建一封電子郵件。 本文介紹了一種VBA方法供您快速解決此問題。

有關在Excel中發送郵件的更多教程...


最佳辦公效率工具

Kutools for Excel解決了您的大多數問題,並使您的生產率提高了80%

  • 重用: 快速插入 複雜的公式,圖表 以及您以前使用過的任何東西; 加密單元 帶密碼 創建郵件列表 並發送電子郵件...
  • 超級公式欄 (輕鬆編輯多行文本和公式); 閱讀版式 (輕鬆讀取和編輯大量單元格); 粘貼到過濾範圍...
  • 合併單元格/行/列 不會丟失數據; 拆分單元格內容; 合併重複的行/列...防止細胞重複; 比較範圍...
  • 選擇重複或唯一 行; 選擇空白行 (所有單元格都是空的); 超級查找和模糊查找 在許多工作簿中; 隨機選擇...
  • 確切的副本 多個單元格,無需更改公式參考; 自動創建參考 到多張紙; 插入項目符號,複選框等...
  • 提取文字,添加文本,按位置刪除, 刪除空間; 創建和打印分頁小計; 在單元格內容和註釋之間轉換...
  • 超級濾鏡 (將過濾方案保存並應用於其他工作表); 高級排序 按月/週/日,頻率及更多; 特殊過濾器 用粗體,斜體...
  • 結合工作簿和工作表; 根據關鍵列合併表; 將數據分割成多個工作表; 批量轉換xls,xlsx和PDF...
  • 超過300種強大功能。 支持Office / Excel 2007-2019和365。支持所有語言。 在您的企業或組織中輕鬆部署。 完整功能30天免費試用。 60天退款保證。
kte選項卡201905

Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 每天將您的工作效率提高50%,並減少數百次鼠標單擊!
officetab底部
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Yogesh Girase · 4 months ago
    hello,

    can you help me on below

    I have create excel sheet & updated 10 supplier mail detail
    I have send mail through excel to all 10 supplier with individual sheet attachment with individual mail.

    I want to paste excel data in outlook body instead of attachment in mail

    can any one help me

  • To post as a guest, your comment is unpublished.
    Arul · 1 years ago
    Hi,
    Instead of selecting the range, I want to select multiple pivots in the excel.
    can you please help me.
  • To post as a guest, your comment is unpublished.
    crystal · 1 years ago
    @Raman Hi Raman,
    In the below code, please replace the range "A1:C5" in line Set xRg = Range("A1:C5") with your own range.

    Sub Send_Email()
    Dim xRg As Range
    Dim I, J As Long
    Dim xAddress As String
    Dim xEmailBody As String
    Dim xMailOut As Outlook.MailItem
    Dim xOutApp As Outlook.Application
    On Error Resume Next
    xAddress = ActiveWindow.RangeSelection.Address
    Set xRg = Range("A1:C5")
    If xRg Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Set xOutApp = CreateObject("Outlook.Application")
    Set xMailOut = xOutApp.CreateItem(olMailItem)
    For I = 1 To xRg.Rows.Count
    For J = 1 To xRg.Columns.Count
    xEmailBody = xEmailBody & " " & xRg.Cells(I, J).Value
    Next
    xEmailBody = xEmailBody & vbNewLine
    Next
    xEmailBody = "Hi" & vbLf & vbLf & " body of message you want to add" & vbLf & vbLf & xEmailBody & vbNewLine
    With xMailOut
    .Subject = "Test"
    .To = "happy.xuebi@163.com"
    .Body = xEmailBody
    .Display
    '.Send
    End With
    Set xMailOut = Nothing
    Set xOutApp = Nothing
    Application.ScreenUpdating = True
    End Sub
  • To post as a guest, your comment is unpublished.
    Raman · 1 years ago
    Hi,
    Instead of selecting the range manually, I want to select the range automatically.
  • To post as a guest, your comment is unpublished.
    prasana05@gmail.com · 1 years ago
    @crystal Hi Crystal, Thank you!
    I had a code created and was wondering how to assign the Command button to the code. Your post helped! and my report works like a charm.

    Thanks again.
  • To post as a guest, your comment is unpublished.
    crystal · 1 years ago
    @Gowtham Hi,
    Please get into the Reference window by clicking Tools > references. Scroll down to find and check the Microsoft Outlook Object Library box and click the OK button to finish the setting.
  • To post as a guest, your comment is unpublished.
    crystal · 1 years ago
    @Ther Hi Ther,
    Can't figure it out. Sorry for that.
  • To post as a guest, your comment is unpublished.
    Ther · 1 years ago
    Hi experts, Do we have updates on how the format maintained?
  • To post as a guest, your comment is unpublished.
    Gowtham · 1 years ago
    i am seeing a compile error (User-defined type not defined". Please help me out to overcome this.
  • To post as a guest, your comment is unpublished.
    sachin kumr · 1 years ago
    this is pasting as a text. Kindly suggest how to send the table or the same format which is copied from the excel.
  • To post as a guest, your comment is unpublished.
    mahajand09@gmail.com · 2 years ago
    @mahajand09@gmail.com Hi, Also I Wanted code for "Filter by Date".
    I am working on project, on that project I wanted to filter the data by the date, actually we have filter/hide the and last 05 days to current date data and we have highlight all other data.
    Please help me to complete this project.
    Your help is very great-full for me.
  • To post as a guest, your comment is unpublished.
    mahajand09@gmail.com · 2 years ago
    @crystal Hi, Is there any update on below.......
  • To post as a guest, your comment is unpublished.
    miguel · 2 years ago
    Code to send automatically after selecting after ok
  • To post as a guest, your comment is unpublished.
    crystal · 2 years ago
    @Dhiraj Mahajan Good Day,
    The problem can't be solved yet. Sorry for the inconvenience and thank you for your comment.
  • To post as a guest, your comment is unpublished.
    Dhiraj Mahajan · 2 years ago
    Hi
    This code is vary excellent, by using the code i have completed my 90% of my project.
    I have same issue as mentioned by Anirudh that is table formatting. How can i format the table in email.
    Please help me......
  • To post as a guest, your comment is unpublished.
    ghosh · 2 years ago
    This is great. It is working as expected. The only issue is that the format of the table is not maintained in the mail. Can you let me know how do we preserve the format of the table in the mail
  • To post as a guest, your comment is unpublished.
    crystal · 2 years ago
    @mfergus Hi Michael,
    You just need to create a button (such as a Button (Form Control)) in your worksheet, then assign the macro to the button.
  • To post as a guest, your comment is unpublished.
    mfergus · 2 years ago
    This code is great, but I need to execute with a command button rather than pressing F5 in code view. I'd like my employees to be able to fill out some info, then hit the button and have it copy the range of cells they completed and paste into email. I can get code working for the email button and separately for the copy/paste of the range of cells, but can't seem to combine both functions. Please help!!! Thanks!