#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 295
Default auto email generator

Hello out there
I'm using the following code which works really well except that each time
it loops around it keeps adding the next attachment. What I want it to do is
to send one email with the first attachment, then send the second email with
the second attachment (only) etc.

I did try deleting the .Add but it didn't make any difference.

Also, can I stop it from sending the pictures in my signature as separate
attachments?

Sub Send_LOAN_APPS()
Application.ScreenUpdating = False
Range("email.app.number").Value = 1

Do While Range("email.app.number").Value <= Range("Number.apps").Value
If Range("email.app.number").Value = 1 Then
Range("Pth.to.send").Value = Range("Pth.APP1").Value
ElseIf Range("email.app.number").Value = 2 Then
Range("Pth.to.send").Value = Range("Pth.APP2").Value
ElseIf Range("email.app.number").Value = 3 Then
Range("Pth.to.send").Value = Range("Pth.APP3").Value
ElseIf Range("email.app.number").Value = 4 Then
Range("Pth.to.send").Value = Range("Pth.APP4").Value
ElseIf Range("email.app.number").Value = 5 Then
Range("Pth.to.send").Value = Range("Pth.APP5").Value
End If

ActiveSheet.Range("Print_Area").Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Introduction = ""
.Item.To = Sheets("LOAN APPS").Range("email.address").Value
.Item.Subject = Sheets("LOAN APPS").Range("email.subject").Value
.Item.Importance = 2
.Item.ReadReceiptRequested = True
.Item.Attachments.Add Range("Pth.to.send").Value
.Item.Send
End With
Range("email.app.number").Value = Range("email.app.number").Value + 1
Loop

Application.ScreenUpdating = True
End Sub


Regards, Brett

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default auto email generator

hi,
Do While Range("email.app.number").Value <= Range("Number.apps").Value???
change this to =
because...
If Range("email.app.number").Value = 5 Then
1,2,3 and 4 will always be less than 5 and code will attach all that are
less than 5.
that's the only thing that looked suspect to me.
not sure if it will work. post back if it does.
also i noticed you referenced 7 ranges. are these named ranges? you didn't
declare the ranges in your code.
regards
FSt1

"Brettjg" wrote:

Hello out there
I'm using the following code which works really well except that each time
it loops around it keeps adding the next attachment. What I want it to do is
to send one email with the first attachment, then send the second email with
the second attachment (only) etc.

I did try deleting the .Add but it didn't make any difference.

Also, can I stop it from sending the pictures in my signature as separate
attachments?

Sub Send_LOAN_APPS()
Application.ScreenUpdating = False
Range("email.app.number").Value = 1

Do While Range("email.app.number").Value <= Range("Number.apps").Value
If Range("email.app.number").Value = 1 Then
Range("Pth.to.send").Value = Range("Pth.APP1").Value
ElseIf Range("email.app.number").Value = 2 Then
Range("Pth.to.send").Value = Range("Pth.APP2").Value
ElseIf Range("email.app.number").Value = 3 Then
Range("Pth.to.send").Value = Range("Pth.APP3").Value
ElseIf Range("email.app.number").Value = 4 Then
Range("Pth.to.send").Value = Range("Pth.APP4").Value
ElseIf Range("email.app.number").Value = 5 Then
Range("Pth.to.send").Value = Range("Pth.APP5").Value
End If

ActiveSheet.Range("Print_Area").Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Introduction = ""
.Item.To = Sheets("LOAN APPS").Range("email.address").Value
.Item.Subject = Sheets("LOAN APPS").Range("email.subject").Value
.Item.Importance = 2
.Item.ReadReceiptRequested = True
.Item.Attachments.Add Range("Pth.to.send").Value
.Item.Send
End With
Range("email.app.number").Value = Range("email.app.number").Value + 1
Loop

Application.ScreenUpdating = True
End Sub


Regards, Brett

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 295
Default auto email generator

Hi FSt1, thanks for that, but itcan't work. The named ranges come from the
Excel sheet and "Number.apps" is pre-detirmined (between 1 and 5).. So I want
the loop to do it for the number of applications that exist. By setting it to
= it doesn't do any.

What I note is that if I run the macro say twice it just keeps adding more
and more loan apps as attachments, so what I need to be able to do is remove
them each time it goes through the loop. The Item.attachments.remove doesn't
work within the With if I put it after the .item.send and nor does it work
if I set up a separate With just to remove.

So the question is: how do I remove the attachments after sending each one?
Regards, Brett

"FSt1" wrote:

hi,
Do While Range("email.app.number").Value <= Range("Number.apps").Value???
change this to =
because...
If Range("email.app.number").Value = 5 Then
1,2,3 and 4 will always be less than 5 and code will attach all that are
less than 5.
that's the only thing that looked suspect to me.
not sure if it will work. post back if it does.
also i noticed you referenced 7 ranges. are these named ranges? you didn't
declare the ranges in your code.
regards
FSt1

"Brettjg" wrote:

Hello out there
I'm using the following code which works really well except that each time
it loops around it keeps adding the next attachment. What I want it to do is
to send one email with the first attachment, then send the second email with
the second attachment (only) etc.

I did try deleting the .Add but it didn't make any difference.

Also, can I stop it from sending the pictures in my signature as separate
attachments?

Sub Send_LOAN_APPS()
Application.ScreenUpdating = False
Range("email.app.number").Value = 1

Do While Range("email.app.number").Value <= Range("Number.apps").Value
If Range("email.app.number").Value = 1 Then
Range("Pth.to.send").Value = Range("Pth.APP1").Value
ElseIf Range("email.app.number").Value = 2 Then
Range("Pth.to.send").Value = Range("Pth.APP2").Value
ElseIf Range("email.app.number").Value = 3 Then
Range("Pth.to.send").Value = Range("Pth.APP3").Value
ElseIf Range("email.app.number").Value = 4 Then
Range("Pth.to.send").Value = Range("Pth.APP4").Value
ElseIf Range("email.app.number").Value = 5 Then
Range("Pth.to.send").Value = Range("Pth.APP5").Value
End If

ActiveSheet.Range("Print_Area").Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Introduction = ""
.Item.To = Sheets("LOAN APPS").Range("email.address").Value
.Item.Subject = Sheets("LOAN APPS").Range("email.subject").Value
.Item.Importance = 2
.Item.ReadReceiptRequested = True
.Item.Attachments.Add Range("Pth.to.send").Value
.Item.Send
End With
Range("email.app.number").Value = Range("email.app.number").Value + 1
Loop

Application.ScreenUpdating = True
End Sub


Regards, Brett

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
Auto Send email from IF command Stuiart Excel Worksheet Functions 0 November 13th 06 03:11 AM
Auto email - With every new entry on my user form Vikram Excel Discussion (Misc queries) 0 June 19th 06 06:00 AM
Auto generate email Phil P Excel Discussion (Misc queries) 1 June 12th 06 10:45 AM
Auto Email superkopite Excel Discussion (Misc queries) 2 January 25th 06 11:49 PM
Auto Email from Excel doesn't appear in Sent Items WimR Excel Discussion (Misc queries) 1 January 6th 05 01:18 AM


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