Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default AUTOMATICALLY SENDING EMAIL VIA A MACRO

Good afternoon excel Gurus,

I currently have a macro button for when pressed it saves the excel sheet
and automatically sends emails to 2 other users in the company to say this
excel sheet is ready for review.

What i now need to happen is when the manager opens this excel sheet I am
going to create an 'Approval' button so when pressed is will say:

Are you sure you want to approve this PIP? Click yes, save as to a specific
location location detailing a cell reference B10 for the name of the file,
click no it will automatically reply to the person who submitted this excel
workbook saying plese review your PIP as it as been declined.

Below you will see my current code for this to work:

Sub save()

ActiveWorkbook.save

Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

strbody = "PIP" & " for " & Sheets("PROFIT IMPROVEMENT
PLAN").Range("B10").Value & " " & _
Sheets("PROFIT IMPROVEMENT PLAN").Range("B11").Value & " " & "Ready For
Review"

On Error Resume Next
With OutMail
.To = ; "
.CC = ""
.BCC = ""
.Subject = "PIP Ready For Review"
.Body = strbody
.Send
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default AUTOMATICALLY SENDING EMAIL VIA A MACRO

try not to use KEYWORDS as sub or variables. So please change
SUB save() to
SUB Approve()
add the two sub (below) and associate ChooseApproveDecline with the button
Clicking the button will ask if you want to Approve, If YES, your original
code is called, if NO the you're asked if you want to decline and the
declined code (yours - just a few changes to the wording) gets sent

then add a Sub Decline
Sub Decline()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

strbody = "PIP" & " for " & Sheets("PROFIT IMPROVEMENT
PLAN").Range("B10").Value & " " & _
Sheets("PROFIT IMPROVEMENT PLAN").Range("B11").Value & " " & "Declined"

On Error Resume Next
With OutMail
.To = ; "
.CC = ""
.BCC = ""
.Subject = "PIP Declined"
.Body = strbody
.Send
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub



Add a new sub

SUB ChooseApproveDecline()
if msgbox("Do you want to Approve?,vbyesNo,"Approve PIP")= vbYes Then
Approve
elseif msgbox("Do you want to Decline?,vbyesNo,"Decline PIP")= vbYes Then
Decline
else
msgbox "Nothing sent"
end if
End Sub


"Neil Holden" wrote:

Good afternoon excel Gurus,

I currently have a macro button for when pressed it saves the excel sheet
and automatically sends emails to 2 other users in the company to say this
excel sheet is ready for review.

What i now need to happen is when the manager opens this excel sheet I am
going to create an 'Approval' button so when pressed is will say:

Are you sure you want to approve this PIP? Click yes, save as to a specific
location location detailing a cell reference B10 for the name of the file,
click no it will automatically reply to the person who submitted this excel
workbook saying plese review your PIP as it as been declined.

Below you will see my current code for this to work:

Sub save()

ActiveWorkbook.save

Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

strbody = "PIP" & " for " & Sheets("PROFIT IMPROVEMENT
PLAN").Range("B10").Value & " " & _
Sheets("PROFIT IMPROVEMENT PLAN").Range("B11").Value & " " & "Ready For
Review"

On Error Resume Next
With OutMail
.To = ;
"
.CC = ""
.BCC = ""
.Subject = "PIP Ready For Review"
.Body = strbody
.Send
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub

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
Macro for Email - Sending to email addresses in cell Brice Excel Programming 2 January 26th 09 07:28 AM
disable spell check whilst automatically sending email from Excel RocketRod Excel Worksheet Functions 0 February 10th 08 11:02 PM
automatically sending workbook daily to email recipient Diane Excel Programming 1 November 8th 06 05:38 PM
Sending Email through a macro rojobrown Excel Worksheet Functions 5 October 12th 06 08:17 PM
Sending an email from a macro sungen99 Excel Programming 1 May 5th 04 07:18 PM


All times are GMT +1. The time now is 09:51 PM.

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

About Us

"It's about Microsoft Excel"