how to email attachement thru a given cell

rakesh seebaruth

Active Member
Joined
Oct 6, 2011
Messages
303
hi there

i have 12 Sub Mail from Sub Mail_ John1() to Sub Mail_ Peter12(). Each individuals have their respectives email addresses. i would like to club all these 12 sub mail(Sub Mail_ John1() to Sub Mail_ Peter12() ) into one single sub Mail. Let's assume that if cell I25=JOHN then email attachment to "john@intnet.mu" . If cell I25=PETER then email attachment to ''peter@intnet.mu'' and so on with the rest. Can you please amend my <acronym title="visual basic for applications">vba</acronym> codes with highlighted in bold. Your help would be much appreciated. thanks for your help


Sub Mail_John1()

Range("b2") = Format(Date, "dd/mmmm/yyyy")

Const mydrive = "R:"

Const mydir = "Credit Admin\Seebaruth Rakesh\SEARCHES NO SIGNATURE"

Dim myname As String

Dim ss As String

myname = Sheets("sheet1").Range("e5").Text & Format(Date, "dd-mmm-yy") & ".xls"

ss = mydrive & "\" & mydir & "\" & myname & ".xls"

Application.DisplayAlerts = False

ActiveWorkbook.SaveCopyAs Filename:=ss

Application.DisplayAlerts = True

Dim i As Long, c As Range

For i = 1 To 2

Set c = Application.InputBox("Click in the cell to insert the Signature", Type:=8)

ActiveSheet.Pictures.Insert ("R:\Credit Admin\Seebaruth Rakesh\rakesh searches\sign.bmp")

With ActiveSheet.Shapes(ActiveSheet.Shapes.Count)

.LockAspectRatio = False

.Top = c.Top

.Left = c.Left

.Height = c.RowHeight

.Width = c.Width

End With

Next i

ActiveSheet.Protect "budget", True, True

Const mydrives = "R:"

Const mydirs = "Credit Admin\Seebaruth Rakesh\rakesh searches\2014"

Dim mynames As String

Dim ms As String

Dim OutApp As Object

Dim OutMail As Object

mynames = Sheets("sheet1").Range("e5").Text & Format(Date, "dd-mmm-yy") & ".xls"

ms = mydrives & "\" & mydirs & "\" & mynames & ".xls"

Application.DisplayAlerts = False

ActiveWorkbook.SaveCopyAs Filename:=ms

Application.DisplayAlerts = True

Set OutApp = CreateObject("Outlook.Application")

Set OutMail = OutApp.CreateItem(0)

On Error Resume Next

With OutMail

.To = "john@intnet.mu"

.CC = ""

.BCC = ""

.Subject = Range("e5")

.Attachments.Add ms

.Send

End With

On Error GoTo 0

Set OutMail = Nothing

Set OutApp = Nothing

ThisWorkbook.Saved = True

Application.Quit

End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,214,798
Messages
6,121,635
Members
449,043
Latest member
farhansadik

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top