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

วิธีแทรกลายเซ็น Outlook เมื่อส่งอีเมลใน Excel

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

แทรกลายเซ็นลงในอีเมล Outlook เมื่อส่งโดย Excel VBA
แทรกลายเซ็น Outlook ได้อย่างง่ายดายเมื่อส่งอีเมลใน Excel ด้วยเครื่องมือที่น่าทึ่ง

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


แทรกลายเซ็นลงในอีเมล Outlook เมื่อส่งโดย Excel VBA

ตัวอย่างเช่น มีรายชื่อที่อยู่อีเมลในเวิร์กชีต เพื่อส่งอีเมลไปยังที่อยู่เหล่านี้ทั้งหมดใน Excel และเพิ่มลายเซ็น Outlook เริ่มต้นในอีเมล โปรดใช้รหัส VBA ด้านล่างเพื่อให้บรรลุ

1. เปิดแผ่นงานที่มีรายการที่อยู่อีเมลที่คุณต้องการส่งอีเมลถึงจากนั้นกดปุ่ม อื่น ๆ + F11 กุญแจ

2. ในการเปิด Microsoft Visual Basic สำหรับแอปพลิเคชัน หน้าต่างคลิก สิ่งที่ใส่เข้าไป > โมดูล, จากนั้นคัดลอกด้านล่าง VBA2 ในหน้าต่างรหัสโมดูล

3. ตอนนี้คุณต้องเปลี่ยนไฟล์ .ร่างกาย เข้าแถว VBA2 ด้วยรหัสใน VBA1. หลังจากนั้นให้ย้ายเส้น .แสดง ใต้เส้น ด้วย xMailOut.

VBA 1: เทมเพลตการส่งอีเมลพร้อมลายเซ็นเริ่มต้นของ Outlook ใน Excel

.HTMLBody = "This is a test email sending in Excel" & "<br>" & .HTMLBody

VBA 2: ส่งอีเมลไปยังที่อยู่อีเมลที่ระบุในเซลล์ใน Excel

Sub SendEmailToAddressInCells()
    Dim xRg As Range
    Dim xRgEach As Range
    Dim xRgVal As String
    Dim xAddress As String
    Dim xOutApp As Outlook.Application
    Dim xMailOut As Outlook.MailItem
    On Error Resume Next
    xAddress = ActiveWindow.RangeSelection.Address
    Set xRg = Application.InputBox("Please select email address range", "KuTools For Excel", xAddress, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Set xOutApp = CreateObject("Outlook.Application")
    Set xRg = xRg.SpecialCells(xlCellTypeConstants, xlTextValues)
    For Each xRgEach In xRg
        xRgVal = xRgEach.Value
        If xRgVal Like "?*@?*.?*" Then
            Set xMailOut = xOutApp.CreateItem(olMailItem)
            With xMailOut
                .To = xRgVal
                .Subject = "Test"
                .Body = "Dear " _
                      & vbNewLine & vbNewLine & _
                        "This is a test email " & _
                        "sending in Excel"
                .Display
                '.Send
            End With
        End If
    Next
    Set xMailOut = Nothing
    Set xOutApp = Nothing
    Application.ScreenUpdating = True
End Sub

ภาพหน้าจอต่อไปนี้สามารถช่วยให้คุณพบความแตกต่างได้อย่างง่ายดายหลังจากเปลี่ยนรหัส VBA

4 กด F5 กุญแจสำคัญในการเรียกใช้รหัส จากนั้นก Kutools สำหรับ Excel เลือกกล่องปรากฏขึ้นโปรดเลือกที่อยู่อีเมลที่คุณจะส่งอีเมลไปให้จากนั้นคลิก ตกลง

จากนั้นอีเมลจะถูกสร้างขึ้น คุณสามารถดูลายเซ็นเริ่มต้นของ Outlook ได้ที่ส่วนท้ายของเนื้อหาอีเมล

ทิปส์:

  • 1. คุณสามารถเปลี่ยนเนื้อหาอีเมลในรหัส VBA 1 ตามความต้องการของคุณ
  • 2. หลังจากรันโค้ดแล้วหากกล่องโต้ตอบข้อผิดพลาดปรากฏขึ้นเตือนว่าไม่ได้กำหนดประเภทที่ผู้ใช้กำหนดโปรดปิดกล่องโต้ตอบนี้จากนั้นไปที่คลิก เครื่องมือ > อ้างอิง ใน Microsoft Visual Basic สำหรับแอปพลิเคชัน หน้าต่าง. ในการเปิด เอกสารอ้างอิง - VBAProject ตรวจสอบหน้าต่าง ไลบรารีวัตถุของ Microsoft Outlook แล้วคลิก ตกลง จากนั้นเรียกใช้รหัสอีกครั้ง

แทรกลายเซ็น Outlook ได้อย่างง่ายดายเมื่อส่งอีเมลใน Excel ด้วยเครื่องมือที่น่าทึ่ง

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

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

ประการแรกคุณต้องสร้างรายชื่ออีเมลที่มีช่องต่างๆที่คุณจะส่งอีเมลตาม

คุณสามารถสร้างรายชื่อส่งเมลด้วยตนเองได้ตามต้องการหรือใช้คุณสมบัติสร้างรายชื่อเมลเพื่อทำให้เสร็จอย่างรวดเร็ว

1 คลิก Kutools พลัส > สร้างรายชื่อผู้รับจดหมาย

2 ใน สร้างรายชื่อผู้รับจดหมาย กล่องโต้ตอบระบุฟิลด์ที่คุณต้องการเลือกตำแหน่งที่จะแสดงรายการจากนั้นคลิกไฟล์ OK ปุ่ม

3. ตอนนี้ตัวอย่างรายชื่อผู้รับจดหมายถูกสร้างขึ้น เนื่องจากเป็นรายการตัวอย่างคุณจึงต้องเปลี่ยนฟิลด์เป็นเนื้อหาที่จำเป็นบางอย่าง (อนุญาตให้มีหลายแถว)

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

5 ใน ส่งอีเมลล์ กล่องโต้ตอบ:

  • 5.1) รายการในรายชื่อผู้รับจดหมายที่เลือกจะถูกวางในช่องที่เกี่ยวข้องโดยอัตโนมัติ
  • 5.2) เสร็จสิ้นเนื้อหาอีเมล
  • 5.3) ตรวจสอบทั้ง ส่งอีเมลผ่าน Outlook และ ใช้การตั้งค่าลายเซ็นของ Outlook กล่อง;
  • 5.4) คลิกปุ่ม ส่ง ปุ่ม. ดูภาพหน้าจอ:

ตอนนี้อีเมลถูกส่ง และลายเซ็น Outlook เริ่มต้นจะถูกเพิ่มที่ส่วนท้ายของเนื้อหาอีเมล

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


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

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

ส่งอีเมลพร้อมการคัดลอกและวางช่วงที่ระบุลงในเนื้อหาอีเมลใน Excel
ในหลาย ๆ กรณีเนื้อหาที่ระบุในแผ่นงาน Excel อาจมีประโยชน์ในการสื่อสารทางอีเมลของคุณ ในบทความนี้เราจะแนะนำวิธีการส่งอีเมลโดยวางช่วงที่ระบุลงในเนื้อหาอีเมลโดยตรงใน 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 (31)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Greetings,

How do i add signature in Email body?

Sub outlook165050()
'
' Send 165050 mail
'
Dim xMailBody As String


'
'Application.Dialogs(xlDialogSendMail).Show
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)



With OutMail
.To = " ; ; "
.CC = " ; ; "
.BCC = ""
.Subject = "165050 Swap VM Movements " & Date
.Body = "Todays VM for 165050 is $0"


.Display
'.Send
End With
End Sub
This comment was minimized by the moderator on the site
Hi Raaj Mehta,

You VBA code has been modified. Please give it a try.

Sub outlook165050()
'
' Send 165050 mail
'
Dim xMailBody As String

'
'Application.Dialogs(xlDialogSendMail).Show
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

With OutMail
.Display
.To = " ;  ; "
.CC = " ;  ; "
.BCC = ""
.Subject = "165050 Swap VM Movements " & Date
.HTMLBody = "Todays VM for 165050 is $0" & "<br>" & .HTMLBody

'.Send
End With
End Sub
This comment was minimized by the moderator on the site
Hello, I am trying to fix my VBA Code. I would like to include one of my outlook signatures with a logo. Is this possible, and where do I put the code that I am currently using? Any assistance would be great.

Sub EmailAspdf()

Dim EApp As Object
Set EApp = CreateObject("Outlook.Application")

Dim EItem As Object
Set EItem = EApp.CreateItem(0)

Dim invno As Long
Dim custname As String
Dim amt As Currency
Dim dt_issue As Date
Dim term As Byte
Dim nextrec As Range
Dim path As String
Dim fname As String

invno = Range("I4")
custname = Range("A11")
amt = Range("I42")
dt_issue = Range("I6")
term = Range("I7")
path = "mypath"
fname = invno & " - " & custname

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, IgnorePrintAreas:=False, Filename:=path & fname

Set nextrec = Sheet3.Range("A1048576").End(xlUp).Offset(1, 0)

nextrec = invno
nextrec.Offset(0, 1) = custname
nextrec.Offset(0, 2) = amt
nextrec.Offset(0, 3) = dt_issue
nextrec.Offset(0, 4) = dt_issue + term
nextrec.Offset(0, 8) = Now

Sheet3.Hyperlinks.Add anchor:=nextrec.Offset(0, 6), Address:=path & fname & ".pdf"

With EItem

.To = Range("A17")

.Subject = Range("A11") & " " & "Invoice No: " & Range("I4") & " " & "for California Advocates"

.body = "Hello " & Range("A11") & "," & vbNewLine & vbNewLine _
& "Please see the attached invoice for " & Range("A11") & "." & vbNewLine & vbNewLine _
& "If you have any questions, please do not hesitate to contact me." & vbNewLine & vbNewLine _
& "Best," & vbNewLine _
& "Mynamehere" & vbNewLine

.Attachments.Add (path & fname & ".pdf")

.Display

End With
Exit Sub



End Sub
This comment was minimized by the moderator on the site
Hi RoseAnne,

You can manually add the logo to your signature in advance before applying the VBA code. The code needs to be put in the Module code window (press the Alt + F11 to open the Visual Basic Editor, click Insert > Module)
This comment was minimized by the moderator on the site
Oi Cristal, a minha macro perde a configuração da assinatura do e-mail, com imagens e formatação original. Como consigo resolver?

Sub Geraremail()

Dim OLapp As Outlook.Application
Dim janela As Outlook.MailItem

Set OLapp = New Outlook.Application
Set janela = OLapp.CreateItem(olMailItem)

Arquivo01 = "Mapa AN"
Anexo01 = ThisWorkbook.Path & "\" & Arquivo01 & ".xlsm"


With janela
ActiveWorkbook.Save
.Display
.To = Sheets("Base").Range("A2").Value
.CC = Sheets("Base").Range("A5").Value
.Subject = "Mapa - Acrilo " & Format(Date, "dd.mm.yy")
assinatura = .Body
.Body = "Prezados/as," & Chr(10) & Chr(10) & "Segue anexo o mapa de Acrilonitrila considerando as vendas previstas no S&OP." & Chr(10) & Chr(10) & assinatura
.Attachments.Add Anexo01
End With

End Sub
This comment was minimized by the moderator on the site
Com a mudança abaixo, consegui ajustar. Porém a letra do corpo da mensagem fica em Times New Roman. Gostaria de usar Calibri, como posso alterar o código?

Sub Geraremail()

Dim OLapp As Outlook.Application
Dim janela As Outlook.MailItem

Set OLapp = New Outlook.Application
Set janela = OLapp.CreateItem(olMailItem)

Arquivo01 = "Mapa AN"
Anexo01 = ThisWorkbook.Path & "\" & Arquivo01 & ".xlsm"


With janela
ActiveWorkbook.Save
.Display
.To = Sheets("Base").Range("A2").Value
.CC = Sheets("Base").Range("A5").Value
.Subject = "Mapa - Acrilo " & Format(Date, "dd.mm.yy")
assinatura = .Body
.HTMLBody = "Prezados/as," & Chr(10) & Chr(10) & "Segue anexo o mapa de Acrilonitrila considerando as vendas previstas no S&OP." & "<br>" & .HTMLBody
.Attachments.Add Anexo01
End With

End Sub
This comment was minimized by the moderator on the site
Hi Milla,
The following VBA code can help you change the font of email body to Calibri, please give it a try. Thank you.
Before running the code, you need to click Tools > Reference in the Microsoft Visual Basic for Applications window, and then check the Microsoft Word Object Library checkbox in the References - VBAProject dialog box as the attached file shown below.
Sub Geraremail()
Dim OLapp As Outlook.Application
Dim janela As Outlook.MailItem
Dim xDoc As Document 'Click Tools > Reference to enable the Microsoft Word Object Library
On Error Resume Next
Set OLapp = New Outlook.Application
Set janela = OLapp.CreateItem(olMailItem)
Arquivo01 = "Mapa AN"
Anexo01 = ThisWorkbook.Path & "\" & Arquivo01 & ".xlsm"
With janela
  ActiveWorkbook.Save
  .Display
  .To = Sheets("Base").Range("A2").Value
  .CC = Sheets("Base").Range("A5").Value
  .Subject = "Mapa - Acrilo " & Format(Date, "dd.mm.yy")
   assinatura = .Body
  .HTMLBody = "Prezados/as," & Chr(10) & Chr(10) & "Segue anexo o mapa de Acrilonitrila considerando as vendas previstas no S&OP." & "<br>" & .HTMLBody
  .Attachments.Add Anexo01
End With
Set xDoc = janela.GetInspector.WordEditor
xDoc.Content.Font.Name = "Calibri"
End Sub
This comment was minimized by the moderator on the site
Hi Milla,
The following VBA code can help you change the font of email body to Calibri, please give it a try. Thank you.
Before running the code, you need to click Tools > Reference in the Microsoft Visual Basic for Applications window, and then check the Microsoft Word Object Library checkbox in the References - VBAProject dialog box as the screenshot shown below.
[img]I:\工作\周雪明\2022年工作\6月份\文章评论截图\3.png[/img]
Sub Geraremail()
Dim OLapp As Outlook.Application
Dim janela As Outlook.MailItem
Dim xDoc As Document 'Click Tools > Reference to enable the Microsoft Word Object Library
On Error Resume Next
Set OLapp = New Outlook.Application
Set janela = OLapp.CreateItem(olMailItem)
Arquivo01 = "Mapa AN"
Anexo01 = ThisWorkbook.Path & "\" & Arquivo01 & ".xlsm"
With janela
  ActiveWorkbook.Save
  .Display
  .To = Sheets("Base").Range("A2").Value
  .CC = Sheets("Base").Range("A5").Value
  .Subject = "Mapa - Acrilo " & Format(Date, "dd.mm.yy")
   assinatura = .Body
  .HTMLBody = "Prezados/as," & Chr(10) & Chr(10) & "Segue anexo o mapa de Acrilonitrila considerando as vendas previstas no S&OP." & "<br>" & .HTMLBody
  .Attachments.Add Anexo01
End With
Set xDoc = janela.GetInspector.WordEditor
xDoc.Content.Font.Name = "Calibri"
End Sub
This comment was minimized by the moderator on the site
I'm trying to send individual sheets from excel to different emails, but it will only attach the workbook itself.  Also, need to be able to add my signature line in.  Any help?Sub AST_Email_From_Excel()

Dim emailApplication As Object
Dim emailItem As Object

Set emailApplication = CreateObject("Outlook.Application")
Set emailItem = emailApplication.CreateItem(0)

' Now we build the email.

emailItem.to = Range("e2").Value

emailItem.CC = Range("g2").Value

emailItem.Subject = "Unreturned Techquidation Equipment"

emailItem.Body = "See the attached spreadsheet for unreturned items in your area"

'Attach current Workbook
emailItem.Attachments.Add ActiveWorkbook.FullName

'Attach any file from your computer.
'emailItem.Attachments.Add ("C:\...)"

'Send the email
'emailItem.send

'Display the email so the user can change it as desired before sending
emailItem.Display

Set emailItem = Nothing
Set emailApplication = Nothing

End Sub
This comment was minimized by the moderator on the site
Hi Chris,The code you provided has been modified. The Outlook signature can now be inserted into the message body. Please give it a try. Thank you.<div data-tag="code">Sub AST_Email_From_Excel()
'Updated by Extendoffice 20220211
Dim emailApplication As Object
Dim emailItem As Object
Set emailApplication = CreateObject("Outlook.Application")
Set emailItem = emailApplication.CreateItem(0)

' Now we build the email.
emailItem.Display 'Display the email so the user can change it as desired before sending
emailItem.to = Range("e2").Value
emailItem.CC = Range("g2").Value
emailItem.Subject = "Unreturned Techquidation Equipment"
emailItem.HTMLBody = "See the attached spreadsheet for unreturned items in your area" & "<br>" & emailItem.HTMLBody

'Attach current Workbook
emailItem.Attachments.Add ActiveWorkbook.FullName

Set emailItem = Nothing
Set emailApplication = Nothing

End Sub
This comment was minimized by the moderator on the site
Hi Crystal,Thank you for getting it to add the signature, doesn't appear to like the HTMLBody section though.When I run the macro, it debugs on emailItem.HTMLBody = "See the attached spreadsheet for unreturned items in your area" & "<br>" & emailItem.HTMLBodyand doesn't complete the rest.  
This comment was minimized by the moderator on the site
Hi,
Which Excel version are you using? The following VBA code also can help. Please give it a try. Thanks for your feedback.<div data-tag="code">Sub SendWorkSheet()
'Update by Extendoffice 20220218
Dim xFile As String
Dim xFormat As Long
Dim Wb As Workbook
Dim Wb2 As Workbook
Dim FilePath As String
Dim FileName As String
Dim OutlookApp As Object
Dim OutlookMail As Object
On Error Resume Next
Application.ScreenUpdating = False
Set Wb = Application.ActiveWorkbook
ActiveSheet.Copy
Set Wb2 = Application.ActiveWorkbook
Select Case Wb.FileFormat
Case xlOpenXMLWorkbook:
xFile = ".xlsx"
xFormat = xlOpenXMLWorkbook
Case xlOpenXMLWorkbookMacroEnabled:
If Wb2.HasVBProject Then
xFile = ".xlsm"
xFormat = xlOpenXMLWorkbookMacroEnabled
Else
xFile = ".xlsx"
xFormat = xlOpenXMLWorkbook
End If
Case Excel8:
xFile = ".xls"
xFormat = Excel8
Case xlExcel12:
xFile = ".xlsb"
xFormat = xlExcel12
End Select
FilePath = Environ$("temp") & "\"
FileName = Wb.Name & Format(Now, "dd-mmm-yy h-mm-ss")
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
Wb2.SaveAs FilePath & FileName & xFile, FileFormat:=xFormat
'xstr = Range("e2") & " ; " & Range("g2")
With OutlookMail
.Display
.To = Range("e2")
.CC = Range("g2")
.BCC = ""
.Subject = "Unreturned Techquidation Equipment"
.HTMLBody = "See the attached spreadsheet for unreturned items in your area" & "<br>" & .HTMLBody
.Attachments.Add Wb2.FullName
'.Send
End With
Wb2.Close
Kill FilePath & FileName & xFile
Set OutlookMail = Nothing
Set OutlookApp = Nothing
Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Looks to be Excel 2016 and VBA 7.1
This comment was minimized by the moderator on the site
It's really helpful code
I need to change text format from right to left In the xOutMsg line
help please .
This comment was minimized by the moderator on the site
I am trying to integrate this code into the current format I currently have whereby I am able to automate emails within excel based on a set range of values. Any help in regard to where to add the 'signature' code within what I currently have would be much appreciated.

Public Sub CheckAndSendMail()

'Updated by Extendoffice 2018/11/22

Dim xRgDate As Range

Dim xRgSend As Range

Dim xRgText As Range

Dim xRgDone As Range

Dim xOutApp As Object

Dim xMailItem As Object

Dim xLastRow As Long

Dim vbCrLf As String

Dim xMailBody As String

Dim xRgDateVal As String

Dim xRgSendVal As String

Dim xMailSubject As String

Dim I As Long

On Error Resume Next

'Please specify the due date range

xStrRang = "D2:D110"

Set xRgDate = Range(xStrRang)

'Please specify the recipients email address range

xStrRang = "C2:C110"

Set xRgSend = Range(xStrRang)

xStrRang = "A2:A110"

Set xRgName = Range(xStrRang)

'Specify the range with reminded content in your email

xStrRang = "Z2:Z110"

Set xRgText = Range(xStrRang)

xLastRow = xRgDate.Rows.Count

Set xRgDate = xRgDate(1)

Set xRgSend = xRgSend(1)

Set xRgName = xRgName(1)

Set xRgText = xRgText(1)

Set xOutApp = CreateObject("Outlook.Application")

For I = 1 To xLastRow

xRgDateVal = ""

xRgDateVal = xRgDate.Offset(I - 1).Value

If xRgDateVal <> "" Then

If CDate(xRgDateVal) - Date <= 30 And CDate(xRgDateVal) - Date > 0 Then

xRgSendVal = xRgSend.Offset(I - 1).Value

xMailSubject = " JBC Service Agreement Expiring On The " & xRgDateVal

vbCrLf = "

"

xMailBody = ""

xMailBody = xMailBody & "Dear " & xRgName.Offset(I - 1).Value & vbCrLf

xMailBody = xMailBody & " " & xRgText.Offset(I - 1).Value & vbCrLf

xMailBody = xMailBody & ""

Set xMailItem = xOutApp.CreateItem(0)

With xMailItem

.Subject = xMailSubject

.To = xRgSendVal

.CC = ""

.HTMLBody = xMailBody

.Display

'.Send

End With

Set xMailItem = Nothing

End If

End If

Next

Set xOutApp = Nothing

End Sub
This comment was minimized by the moderator on the site
Thanks to you, I can add signature now but then it removes spaces between paragraph of text. Please Can you Help me ?


Sub helloworld()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim Path As String
Path = Application.ActiveWorkbook.Path
Set OutApp = CreateObject("Outlook.Application")

For Each cell In Range("C4:C6")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.Display
.To = cell.Value
.Subject = Cells(cell.Row, "D").Value
.HTMLBody = "Dear " & Cells(cell.Row, "B").Value & "," _
& vbNewLine & vbNewLine & _
"Warm Greetings" _
& vbNewLine & vbNewLine & _
"We, JK Overseas, would like to take an opportunity and introduce our company J K Overseas, which is involved in the salt business for the last 3 years. We are currently strong in domestic and expanding overseas. We are the supplier of Edible Salt, Water Softening Salt, De-icing Salt, Industrial Salt" & "." _
& vbNewLine & vbNewLine & _
"We have a tie-up with large scale manufacturers in India and procure from them quality Salt and exports. So, we are looking for a reliable expert importer as well as distributor agent to make a long-term Business with mutual benefit" & "." _
& vbNewLine & vbNewLine & _
"Please contact us with your requirement or for any other inquiries you may have. We provide reliable logistics and on-time delivery. We are confident that our prices being most competitive will match your expectations" & "." _
& vbNewLine & vbNewLine & _
.HTMLBody

'.Send
End With
Next cell
End Sub
This comment was minimized by the moderator on the site
Dear,
Can someone help me with my VBA,
I need the signature in the email created:
This comment was minimized by the moderator on the site
Hi, I would need help with my macro, I need to insert the Outlook signature under the table, could you help me with that?

Private Sub CommandButton1_Click()


Dim outlook As Object
Dim newEmail As Object
Dim xInspect As Object
Dim pageEditor As Object

Set outlook = CreateObject("Outlook.Application")
Set newEmail = outlook.CreateItem(0)

With newEmail
.To = Sheet5.Range("F1")
.CC = ""
.BCC = ""
.Subject = Sheet5.Range("B5")
.Body = Sheet5.Range("B41")
.display

Set xInspect = newEmail.GetInspector
Set pageEditor = xInspect.WordEditor

Sheet5.Range("B6:I7").Copy

pageEditor.Application.Selection.Start = Len(.Body)
pageEditor.Application.Selection.End = pageEditor.Application.Selection.Start
pageEditor.Application.Selection.PasteAndFormat (wdFormatPlainText)

.display
Set pageEditor = Nothing
Set xInspect = Nothing
End With

Set newEmail = Nothing
Set outlook = Nothing

End Sub
This comment was minimized by the moderator on the site
Hi Bara,
Sorry can't help you with that. Thanks for your comment.
This comment was minimized by the moderator on the site
Thanks a lot...
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