Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
developer
active.documents
automation
binary.file_format
clipboard.dde
com.add_ins
hosting.controls
internet_other
office.sdks
officedev
officedev.other
outlook.forms
outlook.vba
smarttags
vba
web.components
  
 
date: Mon, 7 Apr 2008 10:23:45 -0700 (PDT),    group: microsoft.public.office.developer.outlook.forms        back       


How to send an e-mail from a outlook form   
Hi,

I want to send an e-mail message that is created after click of a
button in outlook form (I do NOT want to send the form itself). I have
written following code that is not working.
------------------
Dim oOApp As Outlook.Application
Dim oOMail As Outlook.MailItem

Set oOApp = CreateObject("Outlook.Application")
Set oOMail = oOApp.CreateItem(olMailItem)

With oOMail
.To = "xyz@abc.com"
.Subject = "test"
.Body = "email message"
'.Attachments.Add "\\server\drive\folder\filename", olByValue, 1
.Send
End With
------------------

If you know what the error is or give me a snippet that would work to
send an e-mail with the button click, I would be grateful.

Thanks and regards,
Amit
date: Mon, 7 Apr 2008 10:23:45 -0700 (PDT)   author:   unknown

Re: How to send an e-mail from a outlook form   
This statement does not belong in an Outlook form:

    Set oOApp = CreateObject("Outlook.Application")

Instead, you need to use the intrinsic Application object: 

    Set oOApp = Application

Also, the form must be published for it to run code. See http://outlookcode.com/article.aspx?id=67

-- 
Sue Mosher, Outlook MVP
   Author of Microsoft Outlook 2007 Programming:
     Jumpstart for Power Users and Administrators
    http://www.outlookcode.com/article.aspx?id=54 


 wrote in message news:7a612a19-7042-4f18-bc9b-b70eab8f7c55@m3g2000hsc.googlegroups.com...
> Hi,
> 
> I want to send an e-mail message that is created after click of a
> button in outlook form (I do NOT want to send the form itself). I have
> written following code that is not working.
> ------------------
> Dim oOApp As Outlook.Application
> Dim oOMail As Outlook.MailItem
> 
> Set oOApp = CreateObject("Outlook.Application")
> Set oOMail = oOApp.CreateItem(olMailItem)
> 
> With oOMail
> .To = "xyz@abc.com"
> .Subject = "test"
> .Body = "email message"
> '.Attachments.Add "\\server\drive\folder\filename", olByValue, 1
> .Send
> End With
> ------------------
> 
> If you know what the error is or give me a snippet that would work to
> send an e-mail with the button click, I would be grateful.
> 
> Thanks and regards,
> Amit
date: Mon, 7 Apr 2008 15:38:08 -0400   author:   Sue Mosher [MVP-Outlook]

Re: How to send an e-mail from a outlook form   
On Apr 7, 12:38 pm, "Sue Mosher [MVP-Outlook]"
 wrote:
> This statement does not belong in an Outlook form:
>
>     Set oOApp = CreateObject("Outlook.Application")
>
> Instead, you need to use the intrinsic Application object:
>
>     Set oOApp = Application
>
> Also, the form must be published for it to run code. Seehttp://outlookcode.com/article.aspx?id=67
>
> --
> Sue Mosher, Outlook MVP
>    Author of Microsoft Outlook 2007 Programming:
>      Jumpstart for Power Users and Administrators
>    http://www.outlookcode.com/article.aspx?id=54
>
>
>
>  wrote in messagenews:7a612a19-7042-4f18-bc9b-b70eab8f7c55@m3g2000hsc.googlegroups.com...
> > Hi,
>
> > I want to send an e-mail message that is created after click of a
> > button in outlook form (I do NOT want to send the form itself). I have
> > written following code that is not working.
> > ------------------
> > Dim oOApp As Outlook.Application
> > Dim oOMail As Outlook.MailItem
>
> > Set oOApp = CreateObject("Outlook.Application")
> > Set oOMail = oOApp.CreateItem(olMailItem)
>
> > With oOMail
> > .To = "x...@abc.com"
> > .Subject = "test"
> > .Body = "email message"
> > '.Attachments.Add "\\server\drive\folder\filename", olByValue, 1
> > .Send
> > End With
> > ------------------
>
> > If you know what the error is or give me a snippet that would work to
> > send an e-mail with the button click, I would be grateful.
>
> > Thanks and regards,
> > Amit- Hide quoted text -
>
> - Show quoted text -

Thanks Sue. However I still get the error. I am not sure if one can
send e-mails from the forms.
date: Tue, 8 Apr 2008 10:45:26 -0700 (PDT)   author:   unknown

Re: How to send an e-mail from a outlook form   
Please show your procedure declaration. Do you get any errors? Does other code on the form run?

Note that VBScript does not support data types in variable or procedure declarations, so you need to comment out any As clauses.

-- 
Sue Mosher, Outlook MVP
   Author of Microsoft Outlook 2007 Programming:
     Jumpstart for Power Users and Administrators
    http://www.outlookcode.com/article.aspx?id=54 


 wrote in message news:ff769fd9-fe20-48b1-99e9-378137ee8a4f@d1g2000hsg.googlegroups.com...
On Apr 7, 12:38 pm, "Sue Mosher [MVP-Outlook]"
 wrote:
> This statement does not belong in an Outlook form:
>
> Set oOApp = CreateObject("Outlook.Application")
>
> Instead, you need to use the intrinsic Application object:
>
> Set oOApp = Application
>
> Also, the form must be published for it to run code. See http://outlookcode.com/article.aspx?id=67

>
>  wrote in messagenews:7a612a19-7042-4f18-bc9b-b70eab8f7c55@m3g2000hsc.googlegroups.com...
> > Hi,
>
> > I want to send an e-mail message that is created after click of a
> > button in outlook form (I do NOT want to send the form itself). I have
> > written following code that is not working.
> > ------------------
> > Dim oOApp As Outlook.Application
> > Dim oOMail As Outlook.MailItem
>
> > Set oOApp = CreateObject("Outlook.Application")
> > Set oOMail = oOApp.CreateItem(olMailItem)
>
> > With oOMail
> > .To = "x...@abc.com"
> > .Subject = "test"
> > .Body = "email message"
> > '.Attachments.Add "\\server\drive\folder\filename", olByValue, 1
> > .Send
> > End With
> > ------------------
>
> > If you know what the error is or give me a snippet that would work to
> > send an e-mail with the button click, I would be grateful.
>

Thanks Sue. However I still get the error. I am not sure if one can
send e-mails from the forms.
date: Tue, 8 Apr 2008 14:10:01 -0400   author:   Sue Mosher [MVP-Outlook]

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us