Send mail and contents of body from ms word document

Status
Not open for further replies.

zmagic

Member
Outlook version
Outlook 2013 32 bit
Email Account
IMAP
Hello,

I send mail with this script and the contents of body are cell values, now i want to add the contents from ms word which is in "c:\Email Contents\covering.doc". Please some guide me doing this.

Code:
   Option Explicit
   Sub Send_Files()
   Dim OutApp As Outlook.Application
   Dim OutMail As Outlook.MailItem
   Dim sh As Worksheet
   Dim cell As Range
   Dim FileCell As Range
   Dim rng As Range
 
   With Application
       .EnableEvents = False
       .ScreenUpdating = False
   End With
   Set sh = Sheets("sendemail")
   Set OutApp = CreateObject("Outlook.Application")
       For Each cell In sh.Columns("G").Cells.SpecialCells(xlCellTypeConstants)
       'Enter the path/file names in the C:Z column in each row
     
       Set rng = sh.Cells(cell.Row, 1).Range("K1:Z1")
           
       If cell.Value Like "?*@?*.?*" And _
       LCase(Cells(cell.Row, "H").Value) = "yes" _
       And LCase(Cells(cell.Row, "I").Value) <> "send" And _
       Application.WorksheetFunction.CountA(rng) > 0 Then
        
          Set OutMail = OutApp.CreateItem(olMailItem)
 
   On Error Resume Next
       With OutMail
       .To = cell.Value
       '.CC = ""
       .Subject = "Reports & Statements "
       .Body = "Dear Sir / Madam," & vbNewLine & vbNewLine & _
               "Status : " & cell.Offset(0, 3).Value _
               & vbNewLine & vbNewLine & _
               "Report No.: " & cell.Offset(0, -5).Value _
               & vbNewLine & vbNewLine
     
 [U][B]Get Contents from .doc file 
 
[/B][/U]
               For Each FileCell In rng.SpecialCells(xlCellTypeConstants)
                   If Trim(FileCell) <> "" Then
                       If Dir(FileCell.Value) <> "" Then
                           .Attachments.Add FileCell.Value
                       End If
                   End If
               Next FileCell
              '.Send
               .Display  'Or use Send
           End With 
 
On Error GoTo 0 
 
Cells(cell.Row, "I").Value = "send"
           Set OutMail = Nothing
       End If
   Next cell 
 
cleanup:
   Set OutApp = Nothing
   With Application
       .EnableEvents = True
       .ScreenUpdating = True
   End With 
 
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Have you seen the macro at http://www.outlookcode.com/codedetail.aspx?id=1333 ? That should do what you want to do - it uses the wordmail envelope for the message rather than reading the document and pasting it into the message.

It should work in all versions of outlook.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
M Outlook, send to > mail recipient - results in plain text email Using Outlook 1
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
soadfan Outlook won't send e-mail when offline Outlook VBA and Custom Forms 19
K Delay Send and Mail Merge Outlook VBA and Custom Forms 4
undercover_smother Automatically Forward All Sent Mail and Delete After Send Outlook VBA and Custom Forms 10
stephen li VBA Outlook send mail automatically by specified outlook mail box Outlook VBA and Custom Forms 1
I Outlook 2013 Send mail - it just sticks in Outbox Using Outlook.com accounts in Outlook 0
Tim King Send mail from MSWord through Outlook Using Outlook 3
R OL2010 - Send to Mail Recipient going to wrong account Using Outlook 1
R Unable to send mail using Cox.net Using Outlook 1
Emerogork How do I activate the "Send Again" option in Sent Mail folder? Using Outlook 1
S Check if two organisition is added then i have to give managers passward creteria to send mail Using Outlook 1
A Application_ItemSend not accessed when sending email outside outlook (i.e. word or send to mail from Using Outlook 7
D VBA Script (Ask to where to save send mail) Outlook VBA and Custom Forms 1
D Create additional custom flag descriptions (other than Send E-Mail, Call etc.) Using Outlook 1
A yahoo mail doesn't send or receive reliably Using Outlook 1
H Outlook 2010 unable to send iCloud account e-mail after iOS 7 upgrade Using Outlook 12
C Insert a Date Picker for Send Mail Subject Using Outlook 1
C MsgBox Everytime I send a mail Using Outlook 1
L "sometimes" cant send mail, we have to copy and paste the message and resend? Using Outlook 2
K A program is trying to send an e-mail message on your behalf... Using Outlook 1
L Send E-mail with VBA code from [E-mail Distribution Group] if I have “Send as” Using Outlook 6
S Outllok 2007 VBA code to send mail automatically from drafts folder Using Outlook 1
A How to send Personalized attachment while sending mass mail Using Outlook 1
G Rule: IF mail received by X, THEN no action; IF mail not received by X, SEND Using Outlook 0
E Outlook cannot connect to your incoming (POP3) e-mail server/Cannot send mess. Using Outlook 0
T HELP - Send e-mail verification text box Using Outlook.com accounts in Outlook 10
B How do I create and send mail in Outlook 2003 from code? Using Outlook 5
J Outlook 2003 does not send or receive imap mail from server Using Outlook 0
R OL10 - Send To "Mail Recipient" doesn't go to default email account Using Outlook 23
O Send Mail Via Outlook Even If Outlook Is Closed Using Outlook 4
C send mail every days Outlook VBA and Custom Forms 7
D How can I send a group email to a color catagory re: yellow= mail BCM (Business Contact Manager) 1
T Get rid of having to type verification characters to send mail BCM (Business Contact Manager) 2
H how to send a e-mail with a annex automaticly Outlook VBA and Custom Forms 3
O Scheduled Task Fails running Code to send Outlook Mail from Excel. Outlook VBA and Custom Forms 9
D Outlook 2007 Will Not Send Mail From C# Application Outlook VBA and Custom Forms 7
P Move mail item after send Outlook VBA and Custom Forms 2
G Send Mail If Statement Outlook VBA and Custom Forms 4
Q Error code appears when I try to send e mail Using Outlook 2
S Reading mailitem after mail is send give runtime error. Outlook VBA and Custom Forms 1
R How to restrict GWSMO sync to Outlook Send/Receive cycles Using Outlook 0
pwatts2 Restrict some lists to only BCC send option Outlook Wishlist 2
A Unflag Inbox and Flag Inbox with Orange Category After Item is send Outlook VBA and Custom Forms 3
glnz O365 - How to send from acct 2 but showing email name from acct 1 as From - alias? Using Outlook 0
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
PGSystemTester VBA To Change AppointmentItem.BusyStatus From MeetingItem Before Send Using Outlook 0
C Synchronizing subscribed folders causes hanging during send/receive process Using Outlook 2
M Extract all links from Outlook email, send to Excel Using Outlook 2
A VBA macro for 15 second loop in send and received just for 1 specific mailbox Outlook VBA and Custom Forms 1

Similar threads

Top