A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - Using Contacts
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to tell the macro to use contacts as the email address please.



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 17th 09, 12:11 AM posted to microsoft.public.outlook.contacts
Steved
external usenet poster
 
Posts: 2
Default How to tell the macro to use contacts as the email address please.

Hello from Steved

I've created distribution lists in the Contacts ( Outlook 2007) how can I
please tell the below macro where to look.


Sub MailToDepots()
'Working in 97-2007
Dim wb As Workbook
Dim Shname As Variant
Dim Addr As Variant
Dim N As Integer
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Dim FileFormatNum As Long

Shname = Array("1-City", "1-City", "2-Roskill", "Roskill Tutor",
"3-Papakura", "4-Wiri", "5-Shore", "6-Orewa", "7-Swanson", "8-Panmure")
Addr = Array("steve dee", "1-Depot", "2-Depot", "2-Depot", "4-Depot",
"4-Depot", "5-Depot", "5-Depot", "7-Depot", "1-Depot")


If Val(Application.Version) = 12 Then
'You run Excel 2007
FileExtStr = ".xls": FileFormatNum = 56
Else
'You run Excel 97-2003
FileExtStr = ".xls": FileFormatNum = -4143
End If

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

TempFilePath = Environ$("temp") & "\"

'Create the new workbooks/Mail it/Delete it
For N = LBound(Shname) To UBound(Shname)

TempFileName = "Sheet " & Shname(N) & " " & Format(Now, "dd-mmm-yy
h-mm-ss")

ThisWorkbook.Sheets(Shname(N)).Copy
With ActiveSheet.UsedRange
.Copy
.PasteSpecial Paste:=xlPasteValues
End With
Set wb = ActiveWorkbook

With wb
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormatNum
On Error Resume Next
.SendMail Addr(N), _
"Driver Annulments"
On Error Resume Next
.Close SaveChanges:=False
End With

Kill TempFilePath & TempFileName & FileExtStr

Next N

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Ads
  #2  
Old July 17th 09, 01:35 AM posted to microsoft.public.outlook.contacts
Steved
external usenet poster
 
Posts: 2
Default How to tell the macro to use contacts as the email address please.

Hello from Steved

I'm posting this to another list

Thankyou.

"Steved" wrote:

Hello from Steved

I've created distribution lists in the Contacts ( Outlook 2007) how can I
please tell the below macro where to look.


Sub MailToDepots()
'Working in 97-2007
Dim wb As Workbook
Dim Shname As Variant
Dim Addr As Variant
Dim N As Integer
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Dim FileFormatNum As Long

Shname = Array("1-City", "1-City", "2-Roskill", "Roskill Tutor",
"3-Papakura", "4-Wiri", "5-Shore", "6-Orewa", "7-Swanson", "8-Panmure")
Addr = Array("steve dee", "1-Depot", "2-Depot", "2-Depot", "4-Depot",
"4-Depot", "5-Depot", "5-Depot", "7-Depot", "1-Depot")


If Val(Application.Version) = 12 Then
'You run Excel 2007
FileExtStr = ".xls": FileFormatNum = 56
Else
'You run Excel 97-2003
FileExtStr = ".xls": FileFormatNum = -4143
End If

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

TempFilePath = Environ$("temp") & "\"

'Create the new workbooks/Mail it/Delete it
For N = LBound(Shname) To UBound(Shname)

TempFileName = "Sheet " & Shname(N) & " " & Format(Now, "dd-mmm-yy
h-mm-ss")

ThisWorkbook.Sheets(Shname(N)).Copy
With ActiveSheet.UsedRange
.Copy
.PasteSpecial Paste:=xlPasteValues
End With
Set wb = ActiveWorkbook

With wb
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormatNum
On Error Resume Next
.SendMail Addr(N), _
"Driver Annulments"
On Error Resume Next
.Close SaveChanges:=False
End With

Kill TempFilePath & TempFileName & FileExtStr

Next N

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Set off VBA macro on email receipt then that macro accesses the emailcontent [email protected] Outlook and VBA 3 February 5th 09 12:14 AM
Showing more than one email address for multi address contacts Ralph White Outlook - Using Contacts 6 December 13th 07 01:24 PM
Inserting contacts email address to send when forwarding email. NeliRosi Outlook - General Queries 3 August 10th 06 09:54 PM
Outlook 2002 Uses email address not in Contacts or Address book Pagen Outlook - Using Contacts 1 February 1st 06 05:11 PM
Set which local email account can send mail to contacts in address book. (associating an email address with a contact) Scott Streit Outlook - General Queries 3 January 27th 06 02:57 PM


All times are GMT +1. The time now is 11:09 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.