ไปยังเนื้อหาหลัก

วิธีส่งอีเมลด้วยการคัดลอกและวางช่วงที่ระบุลงในเนื้อหาอีเมลใน Excel

ในหลาย ๆ กรณีเนื้อหาที่ระบุในแผ่นงาน Excel อาจมีประโยชน์ในการสื่อสารทางอีเมลของคุณ ในบทความนี้เราจะแนะนำวิธีการส่งอีเมลโดยวางช่วงที่ระบุลงในเนื้อหาอีเมลโดยตรงใน Excel

ส่งอีเมลพร้อมระบุช่วงที่วางลงในเนื้อหาอีเมลใน Excel
ส่งอีเมลพร้อมระบุช่วงที่วางลงในเนื้อหาอีเมลด้วยเครื่องมือที่น่าทึ่ง

บทช่วยสอนเพิ่มเติมสำหรับการส่งจดหมายใน Excel ...


ส่งอีเมลพร้อมระบุช่วงที่วางลงในเนื้อหาอีเมลใน Excel

รหัส VBA ต่อไปนี้สามารถช่วยให้คุณคัดลอกช่วงและวางลงในเนื้อหาอีเมล Outlook ได้โดยตรงใน Excel กรุณาดำเนินการดังนี้

1. ในแผ่นงานมีช่วงที่คุณต้องการคัดลอกให้กดปุ่ม อื่น ๆ + F11 พร้อมกันเพื่อเปิดไฟล์ Microsoft Visual Basic สำหรับแอปพลิเคชัน หน้าต่าง

2. ในการเปิด Microsoft Visual Basic สำหรับแอปพลิเคชัน โปรดคลิก เครื่องมือ > อ้างอิง ดังภาพด้านล่างที่แสดง

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 = ""
        .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). โปรดระบุผู้รับอีเมลและหัวเรื่องของคุณ (.ถึง = และ . เรื่อง = "ทดสอบ") บรรทัดในรหัส

5 กด F5 กุญแจสำคัญในการเรียกใช้รหัส ในการโผล่ขึ้นมา Kutools สำหรับ Excel โปรดเลือกช่วงที่คุณต้องการวางในเนื้อหาอีเมลจากนั้นคลิกที่ OK ปุ่ม. ดูภาพหน้าจอ:

6. ตอนนี้อีเมลถูกสร้างขึ้นพร้อมระบุผู้รับหัวเรื่องเนื้อหาและช่วงของ Excel ที่เลือกโปรดคลิกที่ไฟล์ ส่ง เพื่อส่งอีเมลนี้ ดูภาพหน้าจอที่แสดง

หมายเหตุ: รหัส VBA จะใช้งานได้ก็ต่อเมื่อคุณใช้ Outlook เป็นโปรแกรมอีเมลของคุณ


ส่งอีเมลพร้อมระบุช่วงที่วางลงในเนื้อหาอีเมลด้วยเครื่องมือที่น่าทึ่ง

หากคุณไม่ได้ใช้ Outlook และยังต้องการส่งอีเมลโดยตรงใน Excel พร้อมกับวางข้อมูลช่วงที่ระบุไว้ภายในฉันขอแนะนำให้ใช้ไฟล์ ส่งอีเมลล์ ประโยชน์ของ Kutools สำหรับ Excel สำหรับคุณ. ด้วยคุณสมบัตินี้คุณเพียงแค่ต้องกำหนดค่าเซิร์ฟเวอร์ขาออกของที่อยู่อีเมลจากนั้นส่งอีเมลใน Excel โดยตรงผ่านที่อยู่อีเมลนี้ในอนาคต

ก่อนที่จะใช้ Kutools สำหรับ Excelโปรด ดาวน์โหลดและติดตั้งในตอนแรก.

1. ประการแรกคุณต้องเตรียมรายชื่อผู้รับจดหมายพร้อมช่องที่จำเป็น

  • เคล็ดลับ: รายชื่ออีเมลต้องมีอย่างน้อย 2 แถวและแถวแรกต้องเป็นส่วนหัว (สมมติว่าคุณต้องการส่งอีเมลไปยังที่อยู่อีเมลสองแห่งใน Excel โปรดพิมพ์ที่อยู่อีเมลทั้งสองนี้โดยมีส่วนหัว "อีเมล" ตามภาพด้านล่างที่แสดง ).
  • หรือคุณสามารถสร้างรายชื่ออีเมลด้วยไฟล์ สร้างรายชื่อผู้รับจดหมาย ลักษณะ

2. เลือกช่วงที่คุณจะเพิ่มข้อมูลลงในเนื้อหาอีเมลแล้วกดปุ่ม Ctrl + C คีย์เพื่อคัดลอก

3. เลือกรายชื่ออีเมลทั้งหมด (รวมส่วนหัว) คลิก Kutools พลัส > ส่งอีเมลล์. ดูภาพหน้าจอ:

4. จากนั้น ส่งอีเมลล์ กล่องโต้ตอบจะปรากฏขึ้น

  • 4.1) รายการของรายชื่อผู้รับจดหมายที่เลือกจะถูกเติมในฟิลด์ที่เกี่ยวข้อง (คุณสามารถเพิ่มฟิลด์เพิ่มเติมในรายชื่ออีเมลได้ตามที่คุณต้องการ)
  • 4.2) คลิกที่กล่องเนื้อหาอีเมลกดปุ่ม Ctrl + V คีย์เพื่อวางข้อมูลช่วงที่เลือกลงในนั้น หลังจากนั้นให้เพิ่มเนื้อหาอื่น ๆ ตามที่คุณต้องการ
  • 4.3 ยกเลิกการเลือก ส่งอีเมลผ่าน Outlook กล่อง;
  • 2.4) คลิกปุ่ม การตั้งค่าเซิร์ฟเวอร์ขาออก ปุ่ม. ดูภาพหน้าจอ:

5. จากนั้น การตั้งค่าเซิร์ฟเวอร์ขาออก (SMTP) - โครงการใหม่ กล่องโต้ตอบจะปรากฏขึ้น โปรดกรอกที่อยู่อีเมลพร้อมการตั้งค่าเซิร์ฟเวอร์ระบุโฟลเดอร์เพื่อบันทึกอีเมลที่ส่งทั้งหมดหลังจากตรวจสอบไฟล์ บันทึกอีเมลที่ส่งไปที่ จากนั้นคลิกที่ไฟล์ OK เพื่อบันทึกการตั้งค่า

6. เมื่อมันกลับไปที่ ส่งอีเมลล์ ใหคลิกปุ the ม ส่ง ปุ่มเพื่อส่งอีเมล

จากนี้ไปคุณสามารถส่งอีเมลพร้อมฟีเจอร์นี้ใน Excel ได้โดยตรง

  หากคุณต้องการทดลองใช้ยูทิลิตีนี้ฟรี (30 วัน) กรุณาคลิกเพื่อดาวน์โหลดแล้วไปใช้การดำเนินการตามขั้นตอนข้างต้น


บทความที่เกี่ยวข้อง:

ส่งอีเมลไปยังที่อยู่อีเมลที่ระบุในเซลล์ใน Excel
สมมติว่าคุณมีรายชื่อที่อยู่อีเมลและคุณต้องการส่งข้อความอีเมลไปยังที่อยู่อีเมลเหล่านี้เป็นกลุ่มโดยตรงใน Excel จะบรรลุได้อย่างไร? บทความนี้จะแสดงวิธีการส่งอีเมลไปยังที่อยู่อีเมลหลายรายการซึ่งระบุไว้ในเซลล์ใน Excel

แทรกลายเซ็น Outlook เมื่อส่งอีเมลใน Excel
สมมติว่าคุณต้องการส่งอีเมลโดยตรงใน Excel คุณจะเพิ่มลายเซ็น Outlook เริ่มต้นในอีเมลได้อย่างไร บทความนี้มีสองวิธีในการช่วยคุณเพิ่มลายเซ็น Outlook เมื่อส่งอีเมลใน Excel

ส่งอีเมลพร้อมไฟล์แนบหลายไฟล์แนบใน Excel
บทความนี้พูดถึงการส่งอีเมลผ่าน Outlook พร้อมแนบไฟล์แนบหลายไฟล์ใน Excel

ส่งอีเมลหากตรงตามวันที่ครบกำหนดใน Excel
ตัวอย่างเช่นหากวันที่ครบกำหนดในคอลัมน์ C น้อยกว่าหรือเท่ากับ 7 วัน (วันที่ปัจจุบันคือ 2017/9/13) ให้ส่งการแจ้งเตือนทางอีเมลไปยังผู้รับที่ระบุในคอลัมน์ A พร้อมเนื้อหาที่ระบุในคอลัมน์ B วิธีการ บรรลุเป้าหมาย? บทความนี้จะให้รายละเอียดเกี่ยวกับวิธีการ VBA เพื่อจัดการกับมัน

ส่งอีเมลโดยอัตโนมัติตามค่าเซลล์ใน Excel
สมมติว่าคุณต้องการส่งอีเมลผ่าน Outlook ไปยังผู้รับบางรายตามค่าเซลล์ที่ระบุใน Excel ตัวอย่างเช่นเมื่อค่าของเซลล์ D7 ในแผ่นงานมากกว่า 200 อีเมลจะถูกสร้างขึ้นโดยอัตโนมัติ บทความนี้แนะนำวิธีการ VBA เพื่อให้คุณแก้ไขปัญหานี้ได้อย่างรวดเร็ว

บทช่วยสอนเพิ่มเติมสำหรับการส่งจดหมายใน Excel ...

สุดยอดเครื่องมือเพิ่มผลผลิตในสำนักงาน

🤖 Kutools AI ผู้ช่วย: ปฏิวัติการวิเคราะห์ข้อมูลโดยยึดตาม: การดำเนินการที่ชาญฉลาด   |  สร้างรหัส  |  สร้างสูตรที่กำหนดเอง  |  วิเคราะห์ข้อมูลและสร้างแผนภูมิ  |  เรียกใช้ฟังก์ชัน Kutools...
คุณสมบัติยอดนิยม: ค้นหา เน้น หรือระบุรายการที่ซ้ำกัน   |  ลบแถวว่าง   |  รวมคอลัมน์หรือเซลล์โดยไม่สูญเสียข้อมูล   |   รอบโดยไม่มีสูตร ...
การค้นหาขั้นสูง: VLookup หลายเกณฑ์    VLookup หลายค่า  |   VLookup ข้ามหลายแผ่น   |   การค้นหาที่ไม่ชัดเจน ....
รายการแบบเลื่อนลงขั้นสูง: สร้างรายการแบบหล่นลงอย่างรวดเร็ว   |  รายการแบบหล่นลงขึ้นอยู่กับ   |  เลือกหลายรายการแบบหล่นลง ....
ผู้จัดการคอลัมน์: เพิ่มจำนวนคอลัมน์เฉพาะ  |  ย้ายคอลัมน์  |  สลับสถานะการมองเห็นของคอลัมน์ที่ซ่อนอยู่  |  เปรียบเทียบช่วงและคอลัมน์ ...
คุณสมบัติเด่น: กริดโฟกัส   |  มุมมองการออกแบบ   |   บาร์สูตรใหญ่    สมุดงานและตัวจัดการชีต   |  ห้องสมุดทรัพยากร (ข้อความอัตโนมัติ)   |  เลือกวันที่   |  รวมแผ่นงาน   |  เข้ารหัส/ถอดรหัสเซลล์    ส่งอีเมลตามรายการ   |  ซุปเปอร์ฟิลเตอร์   |   ตัวกรองพิเศษ (กรองตัวหนา/ตัวเอียง/ขีดทับ...) ...
ชุดเครื่องมือ 15 อันดับแรก12 ข้อความ เครื่องมือ (เพิ่มข้อความ, ลบอักขระ, ... )   |   50 + แผนภูมิ ประเภท (แผนภูมิ Gantt, ... )   |   40+ ใช้งานได้จริง สูตร (คำนวณอายุตามวันเกิด, ... )   |   19 การแทรก เครื่องมือ (ใส่ QR Code, แทรกรูปภาพจากเส้นทาง, ... )   |   12 การแปลง เครื่องมือ (ตัวเลขเป็นคำ, การแปลงสกุลเงิน, ... )   |   7 ผสานและแยก เครื่องมือ (แถวรวมขั้นสูง, แยกเซลล์, ... )   |   ... และอื่น ๆ

เพิ่มพูนทักษะ Excel ของคุณด้วย Kutools สำหรับ Excel และสัมผัสประสิทธิภาพอย่างที่ไม่เคยมีมาก่อน Kutools สำหรับ Excel เสนอคุณสมบัติขั้นสูงมากกว่า 300 รายการเพื่อเพิ่มประสิทธิภาพและประหยัดเวลา  คลิกที่นี่เพื่อรับคุณสมบัติที่คุณต้องการมากที่สุด...

รายละเอียด


แท็บ Office นำอินเทอร์เฟซแบบแท็บมาที่ Office และทำให้งานของคุณง่ายขึ้นมาก

  • เปิดใช้งานการแก้ไขและอ่านแบบแท็บใน Word, Excel, PowerPoint, ผู้จัดพิมพ์, Access, Visio และโครงการ
  • เปิดและสร้างเอกสารหลายรายการในแท็บใหม่ของหน้าต่างเดียวกันแทนที่จะเป็นในหน้าต่างใหม่
  • เพิ่มประสิทธิภาพการทำงานของคุณ 50% และลดการคลิกเมาส์หลายร้อยครั้งให้คุณทุกวัน!
Comments (22)
Rated 4.5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
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, I have the same issue, could you see if you could update it please, otherwise this is excellent.
Many thanks
Rated 4.5 out of 5
This comment was minimized by the moderator on the site
Hi Andy Mitchell,
If you want to maintain the format of the table, the following VBA script can do you a favor. Please give it a try. Thank you.
Sub Send_Email()
'Updated by Extendoffice 20220616
    Dim xRg As Range
    Dim I, J As Long
    Dim xAddress As String
    Dim xMailOut As Object
    Dim xOutApp As Object
    On Error Resume Next
    Set xOutApp = CreateObject("Outlook.Application")
    Set xMailOut = xOutApp.CreateItem(olMailItem)
    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)
    With xMailOut
        .Subject = "Test"
        .To = ""
        .HTMLBody = RangetoHTML(xRg)
        .Display
        '.Send
    End With
    Set xMailOut = Nothing
    Set xOutApp = Nothing
    Application.ScreenUpdating = True
End Sub

 ' The following VBA script is cited from this page:
 ' https://stackoverflow.com/questions/18663127/paste-excel-range-in-outlook
Function RangetoHTML(rng As Range)
' By Ron de Bruin.
    Dim fso As Object
    Dim ts As Object
    Dim TempFile As String
    Dim TempWB As Workbook

    TempFile = Environ$("temp") & "/" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm"

    'Copy the range and create a new workbook to past the data in
    rng.Copy
    Set TempWB = Workbooks.Add(1)
    With TempWB.Sheets(1)
        .Cells(1).PasteSpecial Paste:=8
        .Cells(1).PasteSpecial xlPasteValues, , False, False
        .Cells(1).PasteSpecial xlPasteFormats, , False, False
        .Cells(1).Select
        Application.CutCopyMode = False
        On Error Resume Next
        .DrawingObjects.Visible = True
        .DrawingObjects.Delete
        On Error GoTo 0
    End With

    'Publish the sheet to a htm file
    With TempWB.PublishObjects.Add( _
         SourceType:=xlSourceRange, _
         Filename:=TempFile, _
         Sheet:=TempWB.Sheets(1).Name, _
         Source:=TempWB.Sheets(1).UsedRange.Address, _
         HtmlType:=xlHtmlStatic)
        .Publish (True)
    End With

    'Read all data from the htm file into RangetoHTML
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
    RangetoHTML = ts.ReadAll
    ts.Close
    RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", _
                          "align=left x:publishsource=")

    'Close TempWB
    TempWB.Close savechanges:=False

    'Delete the htm file we used in this function
    Kill TempFile

    Set ts = Nothing
    Set fso = Nothing
    Set TempWB = Nothing
End Function
This comment was minimized by the moderator on the site
This worked perfectly, thank you so much.
I can now add my spin on it to get it doing what I need.
This comment was minimized by the moderator on the site
Hi Paul Johnson,

Very happy to help you solve the problem. Have a good day at work.
This comment was minimized by the moderator on the site
hello,
can you help me on below
I have create excel sheet & updated 10 supplier mail detailI 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
This comment was minimized by the moderator on the site
Hi,
Instead of selecting the range, I want to select multiple pivots in the excel.
can you please help me.
This comment was minimized by the moderator on the site
Hi,
Instead of selecting the range manually, I want to select the range automatically.
This comment was minimized by the moderator on the site
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 = ""
.Body = xEmailBody
.Display
'.Send
End With
Set xMailOut = Nothing
Set xOutApp = Nothing
Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Hi experts, Do we have updates on how the format maintained?
This comment was minimized by the moderator on the site
Hi Ther,
Can't figure it out. Sorry for that.
This comment was minimized by the moderator on the site
i am seeing a compile error (User-defined type not defined". Please help me out to overcome this.
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
this is pasting as a text. Kindly suggest how to send the table or the same format which is copied from the excel.
This comment was minimized by the moderator on the site
Code to send automatically after selecting after ok
This comment was minimized by the moderator on the site
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......
This comment was minimized by the moderator on the site
Good Day,
The problem can't be solved yet. Sorry for the inconvenience and thank you for your comment.
This comment was minimized by the moderator on the site
Hi, Is there any update on below.......
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
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
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations