PDA

View Full Version : Auto Email



KK1966
07-07-2010, 11:22 PM
Hi ALL Experts

Can anyone help me macros to auto send email with attached the XLS file when the excel file click close to target a person ?

Thanks

I used 2003

slamet Harto
07-08-2010, 12:30 AM
adapted from ron debruin code

Sub Mail_workbook_1()
'Working in 97-2007
Dim wb As Workbook
Set wb = ActiveWorkbook
If Val(Application.Version) >= 12 Then
If wb.FileFormat = 51 And wb.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will be no VBA code in the file you send." & vbNewLine & _
"Save the file first as xlsm and then try the macro again.", vbInformation
Exit Sub
End If
End If
On Error ResumeNext
wb.SendMail "ron@debruin.nl", _
"This is the Subject line"
On Error GoTo 0
End Sub

KK1966
07-08-2010, 12:41 AM
thanks the help, but can u send again the code as it was ....and i can't Reorganize...

slamet Harto
07-08-2010, 12:59 AM
upps...

workbook_1()
'Working in 97-2007
Dim wb As Workbook
Set wb = ActiveWorkbook
If Val(Application.Version) >= 12 Then
If wb.FileFormat = 51 And wb.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will be no VBA code in "& _
"the you send." & vbNewLine & _
"Save the file first as xlsm and then try the macro again.", vbInformation
Exit Sub
End If
End If
On Error Resume Next
wb.SendMail "ron@debruin.nl", _
"This is the Subject line"

On Error GoTo 0
End Sub

198188
04-11-2013, 11:46 PM
9863workbook_1()
'Working in 97-2007
Dim wb As Workbook
Set wb = ActiveWorkbook
If Val(Application.Version) >= 12 Then
If wb.FileFormat = 51 And wb.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will be no VBA code in "& _
"the you send." & vbNewLine & _
"Save the file first as xlsm and then try the macro again.", vbInformation
Exit Sub
End If
End If
On Error Resume Next
wb.SendMail "ron@debruin.nl", _
"This is the Subject line"

On Error GoTo 0
End Sub[/quote]

Is it possible as below?

Sheet1 is the contact list as below
a 11111@qq.com
b 11112@qq.com
c 11113@qq.com
d 11114@qq.com

then there have 4's sheet, the sheet name as below
a
b
c
d

Can it auto send
sheet "a" to 11111@qq.com as PDF format
sheet "b" to 11112@qq.com as PDF format
sheet "c" to 11113@qq.com as PDF format
sheet "d" to 11114@qq.com as PDF format