Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-16-2015, 02:11 AM
johnc83 johnc83 is offline VBScript - outlook does not recognize one or more recipients Windows 7 64bit VBScript - outlook does not recognize one or more recipients Office 2003
Novice
VBScript - outlook does not recognize one or more recipients
 
Join Date: Jul 2015
Posts: 6
johnc83 is on a distinguished road
Default VBScript - outlook does not recognize one or more recipients


Hi all, here is the relevant code from my .vbs file. I'm using the recipients.add code to add multiple addresses at once (I know I could add them separately on each line but would really like just the one line if possible).

Anyway, the email is created but fails to send because Outlook 2003 can't resolve the names. If I press 'Check Names' button then it says it doesn't recognise the address (it thinks ALL the addresses are one single address). However, if I put a space in front of the first email address then 'Check Names', it resolves them all instantly. Obviously because this is an automated system I can't put this space in and then check names. Would anyone be able to help me out please? Thanks, John

Code:
Dim objOutl
Set objOutl = CreateObject("Outlook.Application")
Set objMailItem = objOutl.CreateItem(olMailItem)
'comment the next line if you do not want to see the outlook window
objMailItem.Recipients.Add ("john.smith@company.com; dave.jones@company.com; mike.smith@company.com")
objMailItem.Display
objMailItem.Subject = "Daily Report"
objMailItem.Send
Set objMailItem = nothing
Reply With Quote
  #2  
Old 07-16-2015, 06:42 AM
johnc83 johnc83 is offline VBScript - outlook does not recognize one or more recipients Windows 7 64bit VBScript - outlook does not recognize one or more recipients Office 2003
Novice
VBScript - outlook does not recognize one or more recipients
 
Join Date: Jul 2015
Posts: 6
johnc83 is on a distinguished road
Default

I've given up and written an alternative. Its Excel 2003 VBA that is creating the VBS file ready to send the email.

My sub receives a single string (Called 'Recipients') containing multiple email addresses and splits them out into individual ones..

Code:
'GET EMAIL ADDRESSES
EmailList = Recipients
For x = 0 To 10000
If InStr(EmailList, ";") = 0 Then 'if 0 then no more semi-colons meaning you are at last email address in list
x = 10000
Print #fnum, "objMailItem.Recipients.Add (""" & EmailList & """)"
Else
'Get position of semi-colin
SemiColPos = InStr(EmailList, ";")
'Get email address
EmailAddress = Mid(EmailList, 1, SemiColPos - 1)
Print #fnum, "objMailItem.Recipients.Add (""" & EmailAddress & """)"
'remove previous email address from list (by starting new string after first semiCol
EmailList = Mid(EmailList, SemiColPos + 1, 100)
End If
Next
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook invitation shows my entire calendar to recipients deltaskye Outlook 0 04-05-2014 08:24 AM
VBScript - outlook does not recognize one or more recipients VBScript.RegExp: exclude a particular word tinfanide Excel Programming 2 06-07-2012 06:52 AM
VBScript - outlook does not recognize one or more recipients Changed data base name. Outlook doesn't recognize. Skip Outlook 1 10-20-2011 10:55 AM
Outlook 2010 send emails to unintended recipients. enviroko Outlook 7 06-20-2011 06:21 PM
VbScript to Print a .pdf DaveB Excel 2 03-07-2009 12:36 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:17 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft