Μετάβαση στο κύριο περιεχόμενο

Πώς να εισαγάγετε την υπογραφή του Outlook κατά την αποστολή email στο Excel;

Αν υποθέσουμε ότι θέλετε να στείλετε ένα email απευθείας στο Excel, πώς μπορείτε να προσθέσετε την προεπιλεγμένη υπογραφή του Outlook στο email; Αυτό το άρθρο παρέχει δύο μεθόδους που θα σας βοηθήσουν να προσθέσετε υπογραφή του Outlook κατά την αποστολή email στο Excel.

Εισαγάγετε υπογραφή στο email του Outlook κατά την αποστολή μέσω του Excel VBA
Εισαγάγετε εύκολα την υπογραφή του Outlook κατά την αποστολή email στο Excel με ένα καταπληκτικό εργαλείο

Περισσότερα σεμινάρια για αποστολή στο Excel ...


Εισαγάγετε υπογραφή στο email του Outlook κατά την αποστολή μέσω του Excel VBA

Για παράδειγμα, υπάρχει μια λίστα με διευθύνσεις email σε ένα φύλλο εργασίας, για αποστολή email σε όλες αυτές τις διευθύνσεις στο Excel και προσθήκη της προεπιλεγμένης υπογραφής του Outlook στα μηνύματα ηλεκτρονικού ταχυδρομείου. Εφαρμόστε τον παρακάτω κώδικα VBA για να το πετύχετε.

1. Ανοίξτε το φύλλο εργασίας περιέχει τη λίστα διευθύνσεων email στην οποία θέλετε να στείλετε email και, στη συνέχεια, πατήστε το άλλος + F11 κλειδιά.

2. Στο άνοιγμα Microsoft Visual Basic για εφαρμογές παράθυρο, κάντε κλικ στην επιλογή Κύριο θέμα > Μονάδα μέτρησης, και στη συνέχεια αντιγράψτε τα παρακάτω VBA 2 στο παράθυρο κώδικα Module.

3. Τώρα πρέπει να αντικαταστήσετε το .Σώμα γραμμή σε VBA 2 με τον κωδικό στο VBA 1. Μετά από αυτό, μετακινήστε τη γραμμή .Απεικόνιση κάτω από τη γραμμή Με το xMailOut.

VBA 1: Πρότυπο αποστολής email με προεπιλεγμένη υπογραφή του Outlook στο Excel

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

VBA 2: Αποστολή email σε διευθύνσεις email που καθορίζονται σε κελιά στο 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 εμφανίζεται το πλαίσιο επιλογής, επιλέξτε τις διευθύνσεις email στις οποίες θα στείλετε email και, στη συνέχεια, κάντε κλικ στο Εντάξει.

Στη συνέχεια δημιουργούνται email. Μπορείτε να δείτε την προεπιλεγμένη υπογραφή του Outlook να προστίθεται στο τέλος του σώματος του email.

Συμβουλές:

  • 1. Μπορείτε να αλλάξετε το σώμα email στον κωδικό VBA 1 ανάλογα με τις ανάγκες σας.
  • 2. Μετά την εκτέλεση του κώδικα, εάν εμφανιστεί ένα παράθυρο διαλόγου σφάλματος που προειδοποιεί ότι ο καθορισμένος από τον χρήστη τύπος δεν έχει οριστεί, κλείστε αυτόν τον διάλογο και, στη συνέχεια, μεταβείτε στο κλικ Εργαλεία > αναφορές στο Microsoft Visual Basic για εφαρμογές παράθυρο. Στο άνοιγμα Αναφορές - VBAProject παράθυρο, ελέγξτε το Βιβλιοθήκη αντικειμένων του Microsoft Outlook και κάντε κλικ στο κουμπί Εντάξει. Και μετά εκτελέστε ξανά τον κωδικό.

Εισαγάγετε εύκολα την υπογραφή του Outlook κατά την αποστολή email στο Excel με ένα καταπληκτικό εργαλείο

Εάν είστε αρχάριος στο VBA, προτείνουμε εδώ το Αποστολή email χρησιμότητα του Kutools για Excel για σενα. Με αυτήν τη δυνατότητα, μπορείτε εύκολα να στέλνετε μηνύματα ηλεκτρονικού ταχυδρομείου με βάση συγκεκριμένα πεδία στο Excel και να προσθέτετε υπογραφή του Outlook σε αυτά. Κάντε τα εξής:

Πριν από την εφαρμογή Kutools για Excel, σας παρακαλούμε κατεβάστε και εγκαταστήστε το πρώτα.

Πρώτον, πρέπει να δημιουργήσετε μια λίστα αλληλογραφίας με διαφορετικά πεδία στα οποία θα στέλνετε μηνύματα ηλεκτρονικού ταχυδρομείου.

Μπορείτε να δημιουργήσετε μη αυτόματα μια λίστα αλληλογραφίας όπως χρειάζεστε ή να εφαρμόσετε τη δυνατότητα Δημιουργία λίστας αλληλογραφίας για να την ολοκληρώσετε γρήγορα.

1. κλικ Kutools Plus > Δημιουργία λίστας αλληλογραφίας.

2. Στο Δημιουργία λίστας αλληλογραφίας πλαίσιο διαλόγου, καθορίστε τα πεδία που χρειάζεστε, επιλέξτε πού θα εξάγετε τη λίστα και, στη συνέχεια, κάντε κλικ στο OK κουμπί.

3. Τώρα δημιουργείται ένα δείγμα λίστας αλληλογραφίας. Δεδομένου ότι είναι μια λίστα δειγμάτων, πρέπει να αλλάξετε τα πεδία σε συγκεκριμένο απαραίτητο περιεχόμενο. (επιτρέπονται πολλές σειρές)

4. Μετά από αυτό, επιλέξτε ολόκληρη τη λίστα (συμπεριλάβετε κεφαλίδες), κάντε κλικ στο Kutools Plus > Αποστολή email.

5. Στο Αποστολή email κουτί διαλόγου:

  • 5.1) Τα στοιχεία στην επιλεγμένη λίστα αλληλογραφίας τοποθετούνται αυτόματα στα αντίστοιχα πεδία.
  • 5.2) Ολοκληρώστε το σώμα του email.
  • 5.3) Ελέγξτε και τα δύο Αποστολή email μέσω του Outlook και Χρησιμοποιήστε τις ρυθμίσεις υπογραφής του Outlook κουτιά?
  • 5.4) Κάντε κλικ στο Αποστολή κουμπί. Δείτε το στιγμιότυπο οθόνης:

Τώρα αποστέλλονται email. Και η προεπιλεγμένη υπογραφή του Outlook προστίθεται στο τέλος του σώματος email.

  Εάν θέλετε να έχετε μια δωρεάν δοκιμή (30-ημερών) αυτού του βοηθητικού προγράμματος, κάντε κλικ για να το κατεβάσετεκαι μετά πηγαίνετε για να εφαρμόσετε τη λειτουργία σύμφωνα με τα παραπάνω βήματα.


Σχετικά άρθρα:

Αποστολή email σε διευθύνσεις email που καθορίζονται σε κελιά στο Excel
Ας υποθέσουμε ότι έχετε μια λίστα διευθύνσεων email και θέλετε να στείλετε μαζικά μηνύματα ηλεκτρονικού ταχυδρομείου σε αυτές τις διευθύνσεις email απευθείας στο Excel. Πώς να το πετύχετε; Αυτό το άρθρο θα σας δείξει μεθόδους αποστολής email σε πολλές διευθύνσεις email που καθορίζονται σε κελιά στο Excel.

Στείλτε email με αντιγραφή και επικόλληση συγκεκριμένου εύρους στο σώμα email στο Excel
Σε πολλές περιπτώσεις, ένα καθορισμένο εύρος περιεχομένων στο φύλλο εργασίας του Excel μπορεί να είναι χρήσιμο στην επικοινωνία email σας. Σε αυτό το άρθρο, θα παρουσιάσουμε μια μέθοδο αποστολής email με συγκεκριμένη περιοχή επικόλλησης στο σώμα email απευθείας στο Excel.

Στείλτε email με πολλά συνημμένα συνημμένα στο Excel
Αυτό το άρθρο αφορά την αποστολή email μέσω του Outlook με πολλά συνημμένα συνημμένα στο Excel.

Στείλτε email εάν έχει πληρωθεί η προθεσμία στο Excel
Για παράδειγμα, εάν η προθεσμία στη στήλη Γ είναι μικρότερη ή ίση με 7 ημέρες (η τρέχουσα ημερομηνία είναι 2017/9/13), τότε στείλτε μια υπενθύμιση μέσω email στον καθορισμένο παραλήπτη στη στήλη Α με καθορισμένο περιεχόμενο στη στήλη Β. Πώς να να το πετύχετε; Αυτό το άρθρο θα παρέχει μια μέθοδο VBA για την αντιμετώπισή της με λεπτομέρειες.

Αυτόματη αποστολή email με βάση την τιμή κελιού στο Excel
Ας υποθέσουμε ότι θέλετε να στείλετε ένα email μέσω του Outlook σε έναν συγκεκριμένο παραλήπτη με βάση μια καθορισμένη τιμή κελιού στο Excel. Για παράδειγμα, όταν η τιμή του κελιού D7 σε ένα φύλλο εργασίας είναι μεγαλύτερη από 200, τότε δημιουργείται αυτόματα ένα μήνυμα ηλεκτρονικού ταχυδρομείου. Αυτό το άρθρο παρουσιάζει μια μέθοδο VBA για να επιλύσετε γρήγορα αυτό το ζήτημα.

Περισσότερα σεμινάρια για αποστολή στο Excel ...

Τα καλύτερα εργαλεία παραγωγικότητας γραφείου

🤖 Kutools AI Aide: Επανάσταση στην ανάλυση δεδομένων με βάση: Ευφυής Εκτέλεση   |  Δημιουργία κώδικα  |  Δημιουργία προσαρμοσμένων τύπων  |  Αναλύστε δεδομένα και δημιουργήστε γραφήματα  |  Επίκληση Λειτουργιών Kutools...
Δημοφιλή χαρακτηριστικά: Εύρεση, επισήμανση ή αναγνώριση διπλότυπων   |  Διαγραφή κενών γραμμών   |  Συνδυάστε στήλες ή κελιά χωρίς απώλεια δεδομένων   |   Γύρος χωρίς φόρμουλα ...
Σούπερ Αναζήτηση: VLookup πολλαπλών κριτηρίων    VLookup πολλαπλών τιμών  |   VLookup σε πολλά φύλλα   |   Ασαφής αναζήτηση ....
Σύνθετη αναπτυσσόμενη λίστα: Γρήγορη δημιουργία αναπτυσσόμενης λίστας   |  Εξαρτημένη αναπτυσσόμενη λίστα   |  Πολλαπλή αναπτυσσόμενη λίστα ....
Διαχειριστής στήλης: Προσθέστε έναν συγκεκριμένο αριθμό στηλών  |  Μετακίνηση στηλών  |  Εναλλαγή κατάστασης ορατότητας κρυφών στηλών  |  Συγκρίνετε εύρη και στήλες ...
Επιλεγμένα Χαρακτηριστικά: Εστίαση πλέγματος   |  Προβολή σχεδίου   |   Μεγάλη Formula Bar    Διαχείριση βιβλίου εργασίας & φύλλου   |  Βιβλιοθήκη πόρων (Αυτόματο κείμενο)   |  Επιλογή ημερομηνίας   |  Συνδυάστε φύλλα εργασίας   |  Κρυπτογράφηση/Αποκρυπτογράφηση κελιών    Αποστολή email ανά λίστα   |  Σούπερ φίλτρο   |   Ειδικό φίλτρο (φίλτρο με έντονη γραφή/πλάγια γραφή/διαγραφή...) ...
Κορυφαία 15 σύνολα εργαλείων12 Κείμενο Εργαλεία (Προσθήκη κειμένου, Κατάργηση χαρακτήρων, ...)   |   50 + Διάγραμμα Τύποι (Gantt διάγραμμα, ...)   |   40+ Πρακτικό ΜΑΘΗΜΑΤΙΚΟΙ τυποι (Υπολογίστε την ηλικία με βάση τα γενέθλια, ...)   |   19 Εισαγωγή Εργαλεία (Εισαγωγή κωδικού QR, Εισαγωγή εικόνας από το μονοπάτι, ...)   |   12 Μετατροπή Εργαλεία (Αριθμοί σε λέξεις, Μετατροπή Συναλλάγματος, ...)   |   7 Συγχώνευση & διαχωρισμός Εργαλεία (Σύνθετες σειρές συνδυασμού, Διαίρεση κελιών, ...)   |   ... κι αλλα

Αυξήστε τις δεξιότητές σας στο Excel με τα Kutools για Excel και απολαύστε την αποτελεσματικότητα όπως ποτέ πριν. Το Kutools για Excel προσφέρει πάνω από 300 προηγμένες δυνατότητες για την ενίσχυση της παραγωγικότητας και την εξοικονόμηση χρόνου.  Κάντε κλικ εδώ για να αποκτήσετε τη δυνατότητα που χρειάζεστε περισσότερο...

Περιγραφή


Το Office Tab φέρνει τη διεπαφή με καρτέλες στο Office και κάνει την εργασία σας πολύ πιο εύκολη

  • Ενεργοποίηση επεξεργασίας και ανάγνωσης καρτελών σε Word, Excel, PowerPoint, Publisher, Access, Visio και Project.
  • Ανοίξτε και δημιουργήστε πολλά έγγραφα σε νέες καρτέλες του ίδιου παραθύρου και όχι σε νέα παράθυρα.
  • Αυξάνει την παραγωγικότητά σας κατά 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