Can't get this MAPI script to work in vbscript 
Author Message
 Can't get this MAPI script to work in vbscript

remove the "set" --- arrayRecipients is not a COM object...

--
Michael Harris


| The following script is my attempt to convert David Yowell's MAPI script
| (which works very well) from jscript into VBScript. Unfortunately this
| wasn't too successful - the interpreter does not like the line:
|
|   set arrayRecipients = Recipients.split(";")
|
| I get the message "object required". This is probably very simple but I
| can't work it out.
|
| Any ideas?
|
| Thankyou
| David Kanowski
|
|
| ******************************************************
|
| Subject = "MySubject"
| MessageText = "MyMessage"

| MapiProfile = ""
|
|   if (MapiProfile = null) then
|     objShell = CreateObject ("WScript.Shell") ' to work in WSH and HTAs
|     MapiProfile = objShell.RegRead ("HKCU\Software\Microsoft\" +_
|       "Windows Messaging Subsystem\Profiles\DefaultProfile")
|   end if
|
|
|   set objMapi = Wscript.CreateObject("MAPI.Session")
|   objMapi.Logon(MapiProfile)
|   set objMsg = objMapi.Outbox.Messages.Add
|   objMsg.Subject = Subject
|
|   objMsg.Text = MessageText
|   set arrayRecipients = Recipients.split(";")
|   for i = 0 to arrayRecipients.length
|     objRecip = objMsg.Recipients.Add
|     objRecip.Name = arrayRecipients(i)
|     objRecip.Resolve
|   next
|   objMsg.Send
|
|
|
|



Sun, 09 Dec 2001 03:00:00 GMT  
 Can't get this MAPI script to work in vbscript
It is --- Message.Recipients --- is a collection property.

--
Michael Harris


| I just tried that and now I get:
|
| Object required: 'Recipients'
|
| It still seems to think that this is an object.
|
| David Kanowski
|


| > remove the "set" --- arrayRecipients is not a COM object...
| >
| > --
| > Michael Harris
| >
| >
| >


| > | The following script is my attempt to convert David Yowell's MAPI script
| > | (which works very well) from jscript into vbscript. Unfortunately this
| > | wasn't too successful - the interpreter does not like the line:
| > |
| > |   set arrayRecipients = Recipients.split(";")
| > |
| > | I get the message "object required". This is probably very simple but I
| > | can't work it out.
| > |
| > | Any ideas?
| > |
| > | Thankyou
| > | David Kanowski
| > |
| > |
| > | ******************************************************
| > |
| > | Subject = "MySubject"
| > | MessageText = "MyMessage"

| > | MapiProfile = ""
| > |
| > |   if (MapiProfile = null) then
| > |     objShell = CreateObject ("WScript.Shell") ' to work in WSH and HTAs
| > |     MapiProfile = objShell.RegRead ("HKCU\Software\Microsoft\" +_
| > |       "Windows Messaging Subsystem\Profiles\DefaultProfile")
| > |   end if
| > |
| > |
| > |   set objMapi = Wscript.CreateObject("MAPI.Session")
| > |   objMapi.Logon(MapiProfile)
| > |   set objMsg = objMapi.Outbox.Messages.Add
| > |   objMsg.Subject = Subject
| > |
| > |   objMsg.Text = MessageText
| > |   set arrayRecipients = Recipients.split(";")
| > |   for i = 0 to arrayRecipients.length
| > |     objRecip = objMsg.Recipients.Add
| > |     objRecip.Name = arrayRecipients(i)
| > |     objRecip.Resolve
| > |   next
| > |   objMsg.Send
| > |
| > |
| > |
| > |
| >
| >
|
|



Sun, 09 Dec 2001 03:00:00 GMT  
 Can't get this MAPI script to work in vbscript
The following script is my attempt to convert David Yowell's MAPI script
(which works very well) from jscript into vbscript. Unfortunately this
wasn't too successful - the interpreter does not like the line:

  set arrayRecipients = Recipients.split(";")

I get the message "object required". This is probably very simple but I
can't work it out.

Any ideas?

Thankyou
David Kanowski

******************************************************

Subject = "MySubject"
MessageText = "MyMessage"

MapiProfile = ""

  if (MapiProfile = null) then
    objShell = CreateObject ("WScript.Shell") ' to work in WSH and HTAs
    MapiProfile = objShell.RegRead ("HKCU\Software\Microsoft\" +_
      "Windows Messaging Subsystem\Profiles\DefaultProfile")
  end if

  set objMapi = Wscript.CreateObject("MAPI.Session")
  objMapi.Logon(MapiProfile)
  set objMsg = objMapi.Outbox.Messages.Add
  objMsg.Subject = Subject

  objMsg.Text = MessageText
  set arrayRecipients = Recipients.split(";")
  for i = 0 to arrayRecipients.length
    objRecip = objMsg.Recipients.Add
    objRecip.Name = arrayRecipients(i)
    objRecip.Resolve
  next
  objMsg.Send



Mon, 10 Dec 2001 03:00:00 GMT  
 Can't get this MAPI script to work in vbscript
I just tried that and now I get:

Object required: 'Recipients'

It still seems to think that this is an object.

David Kanowski


Quote:
> remove the "set" --- arrayRecipients is not a COM object...

> --
> Michael Harris



> | The following script is my attempt to convert David Yowell's MAPI script
> | (which works very well) from jscript into vbscript. Unfortunately this
> | wasn't too successful - the interpreter does not like the line:
> |
> |   set arrayRecipients = Recipients.split(";")
> |
> | I get the message "object required". This is probably very simple but I
> | can't work it out.
> |
> | Any ideas?
> |
> | Thankyou
> | David Kanowski
> |
> |
> | ******************************************************
> |
> | Subject = "MySubject"
> | MessageText = "MyMessage"

> | MapiProfile = ""
> |
> |   if (MapiProfile = null) then
> |     objShell = CreateObject ("WScript.Shell") ' to work in WSH and HTAs
> |     MapiProfile = objShell.RegRead ("HKCU\Software\Microsoft\" +_
> |       "Windows Messaging Subsystem\Profiles\DefaultProfile")
> |   end if
> |
> |
> |   set objMapi = Wscript.CreateObject("MAPI.Session")
> |   objMapi.Logon(MapiProfile)
> |   set objMsg = objMapi.Outbox.Messages.Add
> |   objMsg.Subject = Subject
> |
> |   objMsg.Text = MessageText
> |   set arrayRecipients = Recipients.split(";")
> |   for i = 0 to arrayRecipients.length
> |     objRecip = objMsg.Recipients.Add
> |     objRecip.Name = arrayRecipients(i)
> |     objRecip.Resolve
> |   next
> |   objMsg.Send
> |
> |
> |
> |



Mon, 10 Dec 2001 03:00:00 GMT  
 Can't get this MAPI script to work in vbscript
Hi David,

have a look into my WSH Bazaar, there is an article how to work with
mapi including a VBScript sample (see the link with the samples). The
sample won't solve exacly your problem, but I guess
you will find a few of suggestions how to use VBScript with collections and
how to handle Outlook objects.

G. Born

Check out WSH Bazaar at:

http://ourworld.compuserve.com/homepages/Guenter_Born/index0.htm

David Kanowski schrieb in Nachricht ...

Quote:
>The following script is my attempt to convert David Yowell's MAPI script
>(which works very well) from jscript into vbscript. Unfortunately this
>wasn't too successful - the interpreter does not like the line:

>  set arrayRecipients = Recipients.split(";")

>I get the message "object required". This is probably very simple but I
>can't work it out.

>Any ideas?

>Thankyou
>David Kanowski

>******************************************************

>Subject = "MySubject"
>MessageText = "MyMessage"

>MapiProfile = ""

>  if (MapiProfile = null) then
>    objShell = CreateObject ("WScript.Shell") ' to work in WSH and HTAs
>    MapiProfile = objShell.RegRead ("HKCU\Software\Microsoft\" +_
>      "Windows Messaging Subsystem\Profiles\DefaultProfile")
>  end if

>  set objMapi = Wscript.CreateObject("MAPI.Session")
>  objMapi.Logon(MapiProfile)
>  set objMsg = objMapi.Outbox.Messages.Add
>  objMsg.Subject = Subject

>  objMsg.Text = MessageText
>  set arrayRecipients = Recipients.split(";")
>  for i = 0 to arrayRecipients.length
>    objRecip = objMsg.Recipients.Add
>    objRecip.Name = arrayRecipients(i)
>    objRecip.Resolve
>  next
>  objMsg.Send



Mon, 10 Dec 2001 03:00:00 GMT  
 Can't get this MAPI script to work in vbscript
I think I have finally got the differences between Jscript and VBscript
cleared up - this bit of scripts seems to work OK:

  arrayRecipients = split(strRecipients,";")
  for i = 0 to ubound(arrayRecipients)
    set objRecip = objMsg.Recipients.Add
    objRecip.Name = arrayRecipients(i)
    objRecip.Resolve
  next
  objMsg.Send

Thanks for the help.

David Kanowski


Quote:
> It is --- Message.Recipients --- is a collection property.

> --
> Michael Harris



> | I just tried that and now I get:
> |
> | Object required: 'Recipients'
> |
> | It still seems to think that this is an object.
> |
> | David Kanowski
> |


> | > remove the "set" --- arrayRecipients is not a COM object...
> | >
> | > --
> | > Michael Harris
> | >
> | >
> | >


> | > | The following script is my attempt to convert David Yowell's MAPI
script
> | > | (which works very well) from jscript into vbscript. Unfortunately
this
> | > | wasn't too successful - the interpreter does not like the line:
> | > |
> | > |   set arrayRecipients = Recipients.split(";")
> | > |
> | > | I get the message "object required". This is probably very simple
but I
> | > | can't work it out.
> | > |
> | > | Any ideas?
> | > |
> | > | Thankyou
> | > | David Kanowski
> | > |
> | > |
> | > | ******************************************************
> | > |
> | > | Subject = "MySubject"
> | > | MessageText = "MyMessage"

> | > | MapiProfile = ""
> | > |
> | > |   if (MapiProfile = null) then
> | > |     objShell = CreateObject ("WScript.Shell") ' to work in WSH and
HTAs
> | > |     MapiProfile = objShell.RegRead ("HKCU\Software\Microsoft\" +_
> | > |       "Windows Messaging Subsystem\Profiles\DefaultProfile")
> | > |   end if
> | > |
> | > |
> | > |   set objMapi = Wscript.CreateObject("MAPI.Session")
> | > |   objMapi.Logon(MapiProfile)
> | > |   set objMsg = objMapi.Outbox.Messages.Add
> | > |   objMsg.Subject = Subject
> | > |
> | > |   objMsg.Text = MessageText
> | > |   set arrayRecipients = Recipients.split(";")
> | > |   for i = 0 to arrayRecipients.length
> | > |     objRecip = objMsg.Recipients.Add
> | > |     objRecip.Name = arrayRecipients(i)
> | > |     objRecip.Resolve
> | > |   next
> | > |   objMsg.Send
> | > |
> | > |
> | > |
> | > |
> | >
> | >
> |
> |



Mon, 10 Dec 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. MAPI Script does not work for a certain curcumstances

2. debugging a WSH-script with microsoft script editor doesn't work

3. Getting the SMTP Email address using CDO/MAPI/Outlook

4. Getting Windows Script Debugger to Work?

5. Problem getting scripts to work

6. Getting UDT's in VBScript

7. Getting UDT's in VBScript

8. Sending MAPI message works from .vbs, but not in ASP

9. CreateObject(MAPI.Session) DOES NOT work on Windows 95

10. Info: simple MAPI works fine

11. GetObject() in VBScript on web page doesn't work

12. ActiveX Control - Line Method won't work in VBScript

 

 
Powered by phpBB® Forum Software