Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default emailing from Excel

H all,
I found the following code in this forum but I need to adapt it a bit to
suit our needs.
When cell value is changed it will send an email to the email address in "A1".

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Me.Range("c8:e13")) Is Nothing Then
With Target
If .Value < "" Then
Dim objOL As New Outlook.Application
Dim objMail As MailItem
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)

msg = "XXXX1" & Chr(13) & Chr(13)
msg = msg & "Payment of £XXXX2 recieved on XXXX3 for the month of XXX4" &
Chr(13)
msg = msg & "Sandra"

addee = Range("a1").Value
CC = Range("b1").Value

With objMail
.To = addee
.CC = CC
.Subject = "Payment received"
.Body = msg
.Display
.Send
End With

Set objMail = Nothing
Set objOL = Nothing

MsgBox "File has been e-mailed to " & addee

End Sub

XXX1 will be the cell on Sheet 1 active row, column "B"
XXX2 will be the value in the cell which has just changed
XXX3 will be today date
XXX4 will be the month which is derived from a constant date in row "C" in
the column above the changed cell

Also, how do I turn off the Outlook warning about an email being sent.
Does any of this make sense???

Thanks
Traa Dy Liooar

Jock
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default emailing from Excel

Hi Jock

See
http://www.rondebruin.nl/mail/prevent.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jock" wrote in message ...
H all,
I found the following code in this forum but I need to adapt it a bit to
suit our needs.
When cell value is changed it will send an email to the email address in "A1".

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Me.Range("c8:e13")) Is Nothing Then
With Target
If .Value < "" Then
Dim objOL As New Outlook.Application
Dim objMail As MailItem
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)

msg = "XXXX1" & Chr(13) & Chr(13)
msg = msg & "Payment of £XXXX2 recieved on XXXX3 for the month of XXX4" &
Chr(13)
msg = msg & "Sandra"

addee = Range("a1").Value
CC = Range("b1").Value

With objMail
.To = addee
.CC = CC
.Subject = "Payment received"
.Body = msg
.Display
.Send
End With

Set objMail = Nothing
Set objOL = Nothing

MsgBox "File has been e-mailed to " & addee

End Sub

XXX1 will be the cell on Sheet 1 active row, column "B"
XXX2 will be the value in the cell which has just changed
XXX3 will be today date
XXX4 will be the month which is derived from a constant date in row "C" in
the column above the changed cell

Also, how do I turn off the Outlook warning about an email being sent.
Does any of this make sense???

Thanks
Traa Dy Liooar

Jock


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default emailing from Excel

Thanks Ron.
I'm currently stuck with 2003 so I'll have to put up with it until 2007
arrives next month!

Cheers,
Jock
--
Traa Dy Liooar

Jock


"Ron de Bruin" wrote:

Hi Jock

See
http://www.rondebruin.nl/mail/prevent.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jock" wrote in message ...
H all,
I found the following code in this forum but I need to adapt it a bit to
suit our needs.
When cell value is changed it will send an email to the email address in "A1".

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Me.Range("c8:e13")) Is Nothing Then
With Target
If .Value < "" Then
Dim objOL As New Outlook.Application
Dim objMail As MailItem
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)

msg = "XXXX1" & Chr(13) & Chr(13)
msg = msg & "Payment of £XXXX2 recieved on XXXX3 for the month of XXX4" &
Chr(13)
msg = msg & "Sandra"

addee = Range("a1").Value
CC = Range("b1").Value

With objMail
.To = addee
.CC = CC
.Subject = "Payment received"
.Body = msg
.Display
.Send
End With

Set objMail = Nothing
Set objOL = Nothing

MsgBox "File has been e-mailed to " & addee

End Sub

XXX1 will be the cell on Sheet 1 active row, column "B"
XXX2 will be the value in the cell which has just changed
XXX3 will be today date
XXX4 will be the month which is derived from a constant date in row "C" in
the column above the changed cell

Also, how do I turn off the Outlook warning about an email being sent.
Does any of this make sense???

Thanks
Traa Dy Liooar

Jock



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
emailing from Excel Roger Excel Discussion (Misc queries) 0 July 2nd 07 07:14 PM
Emailing from Excel tanyhart[_3_] Excel Programming 4 June 8th 06 05:57 PM
Emailing in Excel VBA Srinivas Excel Programming 2 October 20th 04 01:04 PM
emailing from excel selkov Excel Programming 1 February 11th 04 08:56 AM
Emailing from Excel pvp Excel Programming 1 August 4th 03 02:34 PM


All times are GMT +1. The time now is 04:21 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"