#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
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 |
|
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.RegExp: exclude a particular word | tinfanide | Excel Programming | 2 | 06-07-2012 06:52 AM |
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 |