Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Help on mail

Try the following:

Sub SendExcelEmailWithDocument()
Dim r As Integer
Dim attPath As String
Dim strRecipient As String
Dim strBody As String
Dim appOut As Object
Dim outMail As Object

For r = 1 To 1 ' put your current rows in here as r for exampl 2 To 25
ActiveSheet.Cells(r, 1).Select

attPath = "C:\Temp\InsideMSAccess_200701.pdf" 'your attachment if
needed

strRecipient = Range("A1").Value
strBody = "I hope this works..."

Set appOut = CreateObject("Outlook.Application")
appOut.Session.Logon
Set outMail = appOut.CreateItem(0)

With outMail
.To = ActiveCell.Offset(0, 1).Value 'assumes email address is in
Col 2
.Subject = "This is an Excel email test"
.Body = strRecipient & vbCr & vbCr & strBody
.Attachments.Add (attPath)
'.display
'use display and comment out .send if you want to review email prior to
sending it
.send
End With
Next r

Set outMail = Nothing
Set appOut = Nothing

MsgBox "The macro has completed!", vbInformation, "Done!"
End Sub

Good Luck

"singh" wrote:

Hi to all

Scenerio: I have a sheet with full of mailing address and name of that
particular person and a word document in C drive.

Question: Can I create a macro for sending mail to all the person in the
excel sheet with name as salutation in mail and attach the word document?
Column A contains Name of person
Column B contains Email ID
For sending mail to a particular person I generally use the below code:
Sub SendActiveWorkbook()
ActiveWorkbook.SendMail _
", _
Subject:="As per the mail content " & Format(Date, "dd/mmm/yy")
End Sub
This is only for the active sheet. I do not know how to attach word document
through macro.

Thanks in advance

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert to HTML and e-mail selection as the body of the e-mail. ryanmhess Excel Programming 5 April 16th 09 01:28 AM
Error: cannot load the mail service. Check your mail installation. Brad Bowser Excel Discussion (Misc queries) 0 December 20th 05 10:03 PM
General mail failure when sending e-mail from Excel Adrienne Excel Discussion (Misc queries) 5 November 4th 05 12:59 PM
Creating TWO-WAY E-Mail Attachments with 'BeforeSave Events' in Code for 2nd E-Mail Chuckles123[_112_] Excel Programming 0 September 8th 05 05:56 PM


All times are GMT +1. The time now is 10:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"