Note: The other languages of the website are Google-translated. Back to English
Mewngofnodi  \/ 
x
or
x
Cofrestru  \/ 
x

or

Sut i fewnosod llofnod Outlook wrth anfon e-bost yn Excel?

Gan dybio eich bod am anfon e-bost yn uniongyrchol yn Excel, sut allwch chi ychwanegu'r llofnod Outlook rhagosodedig yn eich e-bost? Mae'r erthygl hon yn darparu dau ddull i'ch helpu chi i ychwanegu llofnod Outlook wrth anfon e-bost yn Excel.

Mewnosodwch lofnod yn e-bost Outlook wrth ei anfon gan Excel VBA
Mewnosod llofnod Outlook yn hawdd wrth anfon e-bost yn Excel gydag offeryn anhygoel

Mwy o sesiynau tiwtorial ar gyfer postio yn Excel ...


Mewnosodwch lofnod yn e-bost Outlook wrth ei anfon gan Excel VBA

Er enghraifft, mae rhestr o gyfeiriadau e-bost mewn taflen waith, ac mae angen i chi anfon e-bost at yr holl gyfeiriadau hyn yn Excel a chynnwys y llofnod Outlook diofyn ym mhob e-bost. Defnyddiwch y cod VBA isod i'w gyflawni.

1. Mae agor y daflen waith yn cynnwys y rhestr cyfeiriadau e-bost rydych chi am e-bostio ati, ac yna pwyswch y Alt + F11 allweddi.

2. Yn yr agoriad Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, cliciwch Mewnosod > Modiwl, ac yna copïwch yr isod VBA 2 i mewn i ffenestr cod y Modiwl.

3. Nawr mae angen i chi ddisodli'r .Body llinell i mewn VBA 2 gyda'r cod i mewn VBA 1. Ar ôl hynny, torri'r .Display llinell ac yna ei gludo o dan y Gyda xMailOut llinell.

VBA 1: Templed o anfon e-bost gyda llofnod yn Excel

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

VBA 2: Anfon e-bost i gyfeiriadau e-bost a bennir mewn celloedd yn 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

Gall y screenshot canlynol eich helpu i ddod o hyd i'r gwahaniaethau yn hawdd ar ôl newid y cod VBA.

4. Gwasgwch y F5 allwedd i redeg y cod. Yna a Kutools ar gyfer Excel dewiswch naidlenni, dewiswch y cyfeiriadau e-bost y byddwch yn anfon e-byst atynt, ac yna cliciwch OK.

Yna mae e-byst sy'n anfon i gyfeiriadau penodol yn cael eu creu a'u harddangos. Gallwch weld bod llofnod rhagosodedig Outlook yn cael ei ychwanegu ar ddiwedd y corff e-bost.

Awgrym:

  • 1. Gallwch newid y corff e-bost yng nghod 1 VBA yn seiliedig ar eich anghenion.
  • 2. Ar ôl rhedeg y cod, os bydd blwch deialog gwall yn ymddangos nad yw'r math a ddiffiniwyd gan y Defnyddiwr wedi'i ddiffinio, caewch y dialog hwn, ac yna ewch i glicio offer > cyfeiriadau yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr. Yn yr agoriad Cyfeiriadau - VBAProject ffenestr, gwiriwch y Llyfrgell Gwrthrychau Microsoft Outlook blwch a chlicio OK. Ac yna rhedeg y cod eto.

Mewnosod llofnod Outlook yn hawdd wrth anfon e-bost yn Excel gydag offeryn anhygoel

Os ydych chi'n newbie yn VBA, dyma argymell y Anfon E-byst cyfleustodau Kutools ar gyfer Excel i chi. Gyda'r nodwedd hon, gallwch chi anfon e-byst yn hawdd yn seiliedig ar rai meysydd yn Excel ac ychwanegu llofnod Outlook atynt. Gwnewch fel a ganlyn.

Cyn gwneud cais Kutools ar gyfer Excel, os gwelwch yn dda ei lawrlwytho a'i osod yn gyntaf.

Yn gyntaf, mae angen i chi greu rhestr bostio gyda gwahanol feysydd y byddwch chi'n anfon e-byst yn seiliedig arnyn nhw.

Gallwch chi greu rhestr bostio â llaw yn ôl yr angen neu gymhwyso'r nodwedd Creu Rhestr Postio i'w chyflawni'n gyflym.

1. Cliciwch Kutools Plus > Creu Rhestr Bostio.

2. Yn y Creu Rhestr Bostio blwch deialog, nodwch y meysydd sydd eu hangen arnoch chi, dewiswch ble i allbynnu'r rhestr, ac yna cliciwch ar y OK botwm.

3. Nawr mae sampl rhestr bostio yn cael ei chreu. Gan ei fod yn rhestr sampl, mae angen ichi newid y meysydd i gynnwys penodol sydd ei angen. (caniateir rhesi lluosog)

4. Ar ôl hynny, dewiswch y rhestr gyfan (cynnwys penawdau), cliciwch Kutools Plus > Anfon E-byst.

5. Yn y Anfon E-byst blwch deialog:

  • 5.1) Rhoddir eitemau yn y rhestr bostio a ddewiswyd mewn meysydd cyfatebol yn awtomatig;
  • 5.2) Gorffennwch y corff e-bost;
  • 5.3) Gwiriwch y ddau Anfon e-bost trwy Outlook a Defnyddiwch osodiadau llofnod Outlook blychau;
  • 5.4) Cliciwch y anfon botwm. Gweler y screenshot:

Nawr anfonir e-byst. Ac ychwanegir llofnod rhagosodedig Outlook ar ddiwedd y corff e-bost.

  Os ydych chi am gael treial am ddim (30 diwrnod) o'r cyfleustodau hwn, cliciwch i'w lawrlwytho, ac yna ewch i gymhwyso'r llawdriniaeth yn ôl y camau uchod.


Erthyglau cysylltiedig:

Anfon e-bost i gyfeiriadau e-bost a bennir mewn celloedd yn Excel
Gan dybio bod gennych chi restr o gyfeiriadau e-bost, a'ch bod chi am anfon neges e-bost i'r cyfeiriadau e-bost hyn mewn swmp yn uniongyrchol yn Excel. Sut i'w gyflawni? Bydd yr erthygl hon yn dangos dulliau i chi o anfon e-bost i gyfeiriadau e-bost lluosog a nodwyd mewn celloedd yn Excel.

Anfon e-bost gyda chopïo a gludo ystod benodol i'r corff e-bost yn Excel
Mewn llawer o achosion, gallai ystod benodol o gynnwys yn nhaflen waith Excel fod yn ddefnyddiol yn eich cyfathrebiad e-bost. Yn yr erthygl hon, byddwn yn cyflwyno dull o anfon e-bost gydag pasting ystod benodol i'r corff e-bost yn uniongyrchol yn Excel.

Anfon e-bost gydag atodiadau lluosog ynghlwm yn Excel
Mae'r erthygl hon yn sôn am anfon e-bost trwy Outlook gyda nifer o atodiadau ynghlwm yn Excel.

Anfon e-bost os yw'r dyddiad dyledus wedi'i fodloni yn Excel
Er enghraifft, os yw'r dyddiad dyledus yng ngholofn C yn llai na neu'n hafal i 7 diwrnod (y dyddiad cyfredol yw 2017/9/13), yna anfonwch nodyn atgoffa e-bost at y derbynnydd penodedig yng ngholofn A gyda chynnwys penodol yng ngholofn B. Sut i ei gyflawni? Bydd yr erthygl hon yn darparu dull VBA i ddelio ag ef yn fanwl.

Anfon e-bost yn awtomatig yn seiliedig ar werth celloedd yn Excel
Gan dybio eich bod am anfon e-bost trwy Outlook at dderbynnydd penodol yn seiliedig ar werth celloedd penodol yn Excel. Er enghraifft, pan fydd gwerth cell D7 mewn taflen waith yn fwy na 200, yna crëir e-bost yn awtomatig. Mae'r erthygl hon yn cyflwyno dull VBA i chi ddatrys y mater hwn yn gyflym.

Mwy o sesiynau tiwtorial ar gyfer postio yn Excel ...


Yr Offer Cynhyrchedd Swyddfa Gorau

Mae Kutools for Excel yn Datrys y rhan fwyaf o'ch Problemau, ac yn Cynyddu Eich Cynhyrchedd 80%

  • Ailddefnyddio: Mewnosod yn gyflym fformwlâu cymhleth, siartiau ac unrhyw beth rydych chi wedi'i ddefnyddio o'r blaen; Amgryptio Celloedd gyda chyfrinair; Creu Rhestr Bostio ac anfon e-byst ...
  • Bar Fformiwla Gwych (golygu llinellau lluosog o destun a fformiwla yn hawdd); Cynllun Darllen (darllen a golygu nifer fawr o gelloedd yn hawdd); Gludo i'r Ystod Hidlo...
  • Uno Celloedd / Rhesi / Colofnau heb golli Data; Cynnwys Celloedd Hollt; Cyfuno Rhesi / Colofnau Dyblyg... Atal Celloedd Dyblyg; Cymharwch y Meysydd...
  • Dewiswch Dyblyg neu Unigryw Rhesi; Dewiswch Blank Rows (mae pob cell yn wag); Darganfyddiad Gwych a Darganfyddiad Niwlog mewn Llawer o Lyfrau Gwaith; Dewis ar Hap ...
  • Copi Union Celloedd Lluosog heb newid cyfeirnod fformiwla; Auto Creu Cyfeiriadau i Daflenni Lluosog; Mewnosod Bwledi, Blychau Gwirio a mwy ...
  • Testun Detholiad, Ychwanegu Testun, Tynnu yn ôl Swydd, Tynnwch y Gofod; Creu ac Argraffu Subtotals Paging; Trosi rhwng Cynnwys a Sylwadau Celloedd...
  • Hidlo Super (arbed a chymhwyso cynlluniau hidlo i ddalenni eraill); Trefnu Uwch yn ôl mis / wythnos / dydd, amlder a mwy; Hidlo Arbennig gan feiddgar, italig ...
  • Cyfuno Llyfrau Gwaith a Thaflenni Gwaith; Uno Tablau yn seiliedig ar golofnau allweddol; Rhannwch Ddata yn Daflenni Lluosog; Trosi Swp xls, xlsx a PDF...
  • Mwy na 300 o nodweddion pwerus. Yn cefnogi Swyddfa / Excel 2007-2019 a 365. Yn cefnogi pob iaith. Defnydd hawdd yn eich menter neu sefydliad. Nodweddion llawn treial am ddim 30 diwrnod. Gwarant arian yn ôl 60 diwrnod.
tab kte 201905

Mae Tab Office yn Dod â rhyngwyneb Tabbed i'r Swyddfa, a Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
gwaelod 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.
    samer · 16 days ago
    It's really helpful code
    I need to change text format from right to left In the xOutMsg line
    help please .
  • To post as a guest, your comment is unpublished.
    Fevro1 · 1 years ago
    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 = "mailcc@justbettercare.com"
    .HTMLBody = xMailBody
    .Display
    '.Send
    End With
    Set xMailItem = Nothing
    End If
    End If
    Next
    Set xOutApp = Nothing
    End Sub
  • To post as a guest, your comment is unpublished.
    kanojiyajay161196@gmail.com · 2 years ago
    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
  • To post as a guest, your comment is unpublished.
    fadysam · 2 years ago
    Dear,
    Can someone help me with my VBA,
    I need the signature in the email created:
  • To post as a guest, your comment is unpublished.
    Bara · 2 years ago
    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
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi Bara,
      Sorry can't help you with that. Thanks for your comment.
  • To post as a guest, your comment is unpublished.
    Kasun · 2 years ago
    Thanks a lot...
  • To post as a guest, your comment is unpublished.
    Prakash · 2 years ago
    Superb!!!!
  • To post as a guest, your comment is unpublished.
    Michael · 3 years ago
    I'm having trouble running this on excel 2016. I get a "Compile Error: User Defined Type Not Defined" message. Please help!
  • To post as a guest, your comment is unpublished.
    Maggie · 3 years ago
    If my body text is linked to pull from excel fields, the use of & .HTMLBody at the end of the string erases all of the body text and just leaves the signature.
  • To post as a guest, your comment is unpublished.
    viraj Shirsat · 3 years ago
    how to add signature if the macro is used by multiple user.
    for eg my macro will be run by 3 other persons as well. So how can the macro use the signature of the user who is running the macro.
    thanks in advance
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Good Day,
      The VBA code can automatically recognize the default signature in the Outlook of the sender, and send email with his own signature through Outlook.
  • To post as a guest, your comment is unpublished.
    kkoruni · 3 years ago
    i am trying to add the outlook signature titled "default" but cannot seem that it works.
    can you please help? I believe that my "xMailout" logic is wrong. this is my suspected faulty area.

    Private Sub CommandButton1_Click()

    Dim xOutApp As Object
    Dim xOutMail As Object
    Dim xMailBody As String
    Dim xMailOut As Outlook.MailItem
    On Error Resume Next
    Set xOutApp = CreateObject("Outlook.Application")
    Set xOutMail = xOutApp.CreateItem(0)
    xMailBody = "Greetings:" & vbNewLine & vbNewLine & _
    "This is line 1" & vbNewLine & _
    "This is line 2" & vbNewLine & _
    "This is line 3" & vbNewLine & _
    "This is line 4"
    On Error Resume Next
    With xOutMail
    .To = "Email.here.com"
    .CC = "Email.here.com"
    .Subject = "Email Title Here - " & Range("Cell#").value
    .Body = xMailBody
    . Attachments.Add ActiveWorkbook.FullName
    Set xMailOut = xOutApp.CreateItem(olMailItem)
    With xMailOut
    .Display
    End With
    ActiveWorkbook.Save
    On Error GoTo 0
    Set xOutMail = Nothing
    Set xOutApp = Nothing
    End Sub
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Good day,
      You script has been modified, please have try. Thank you.

      Private Sub CommandButton1_Click()
      Dim xOutApp As Object
      Dim xOutMail As Object
      Dim xMailBody As String
      Dim xMailOut As Outlook.MailItem
      On Error Resume Next
      Set xOutApp = CreateObject("Outlook.Application")
      Set xOutMail = xOutApp.CreateItem(0)
      xMailBody = "Greetings:" & vbNewLine & vbNewLine & _
      "This is line 1" & vbNewLine & _
      "This is line 2" & vbNewLine & _
      "This is line 3" & vbNewLine & _
      "This is line 4"
      On Error Resume Next
      With xOutMail
      .To = "Email.here.com"
      .CC = "Email.here.com"
      .Subject = "Email Title Here - " & Range("Cell#").Value
      .Body = xMailBody
      .Attachments.Add ActiveWorkbook.FullName
      Set xMailOut = xOutApp.CreateItem(olMailItem)
      With xMailOut
      .Display
      End With
      End With
      ActiveWorkbook.Save
      On Error GoTo 0
      Set xOutMail = Nothing
      Set xOutApp = Nothing
      End Sub
  • To post as a guest, your comment is unpublished.
    Chris · 3 years ago
    doesnt work with attachments in Office 2016
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Chris,
      The below VBA code can help you. After running the code, please select cells containing email addresses you will send emails to, and then select the files you need to attach in the email as attachments when the second dialog box pops up. And the default Outlook signature will be displayed in the email body as well. Thank you for your comment.

      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)
      Set xFileDlg = Application.FileDialog(msoFileDialogFilePicker)
      If xFileDlg.Show = -1 Then
      For Each xRgEach In xRg
      xRgVal = xRgEach.Value
      If xRgVal Like "?*@?*.?*" Then
      Set xMailOut = xOutApp.CreateItem(olMailItem)
      With xMailOut
      .Display
      .To = xRgVal
      .Subject = "Test"
      .HTMLBody = "This is a test email sending in Excel" & "
      " & .HTMLBody
      For Each xFileDlgItem In xFileDlg.SelectedItems
      .Attachments.Add xFileDlgItem
      Next xFileDlgItem
      '.Send
      End With
      End If
      Next
      Set xMailOut = Nothing
      Set xOutApp = Nothing
      Application.ScreenUpdating = True
      End If
      End Sub
  • To post as a guest, your comment is unpublished.
    Favio · 3 years ago
    thank u very much, u save my life with this template :D
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Favio,
      Glad to help.