Set and Email's To and Subject Fields 
Author Message
 Set and Email's To and Subject Fields

hi,
how do i programatically set the TO and SUBJECT fields of a Word email.  I
am using the contents of an RTF created from an access report as the
contents of the email.  thanks in advance

This is what i have so far:

    strAttachmentName = "c:\temp\Wash-" & Format(Date, "mmddyy") & ".txt"
    'output the report to a text file
    DoCmd.OutputTo acOutputReport, strDocName, acFormatRTF,
strAttachmentName

    Dim app As New Word.Application
    Dim doc As Word.Document

    app.Documents.Open strAttachmentName
    app.Options.SendMailAttach = False
    Set doc = app.ActiveDocument
    'I NEED TO SET THE TO AND SUBJECT LINES HERE
    app.ActiveDocument.SendMail

    doc.Close
    Set doc = Nothing
    app.Quit
    Set app = Nothing



Tue, 16 Mar 2004 17:24:29 GMT  
 Set and Email's To and Subject Fields
Hi Allen

Have you seen the article at
http://www.mvps.org/word/FAQs/InterDev/SendMail.htm by Astrid, one of the
Word MVPs. It does not answer you question but offers two different
approaches.

--
Anna Bohman
Bra Utbildning AB, Sweden


Quote:
> hi,
> how do i programatically set the TO and SUBJECT fields of a Word email.  I
> am using the contents of an RTF created from an access report as the
> contents of the email.  thanks in advance

> This is what i have so far:

>     strAttachmentName = "c:\temp\Wash-" & Format(Date, "mmddyy") & ".txt"
>     'output the report to a text file
>     DoCmd.OutputTo acOutputReport, strDocName, acFormatRTF,
> strAttachmentName

>     Dim app As New Word.Application
>     Dim doc As Word.Document

>     app.Documents.Open strAttachmentName
>     app.Options.SendMailAttach = False
>     Set doc = app.ActiveDocument
>     'I NEED TO SET THE TO AND SUBJECT LINES HERE
>     app.ActiveDocument.SendMail

>     doc.Close
>     Set doc = Nothing
>     app.Quit
>     Set app = Nothing



Tue, 16 Mar 2004 17:38:21 GMT  
 Set and Email's To and Subject Fields
Hi Allen,

Look up in help: SendObject
Goes like this:

DoCmd.SendObject acSendReport, "MyReportName", _


    Subject:="This is your subject", _
    Messagetext:="Goodday," & vbr & "This is a line" & vbCr & "Kind regards"

Kind regards,
Perry



Quote:
> hi,
> how do i programatically set the TO and SUBJECT fields of a Word email.  I
> am using the contents of an RTF created from an access report as the
> contents of the email.  thanks in advance

> This is what i have so far:

>     strAttachmentName = "c:\temp\Wash-" & Format(Date, "mmddyy") & ".txt"
>     'output the report to a text file
>     DoCmd.OutputTo acOutputReport, strDocName, acFormatRTF,
> strAttachmentName

>     Dim app As New Word.Application
>     Dim doc As Word.Document

>     app.Documents.Open strAttachmentName
>     app.Options.SendMailAttach = False
>     Set doc = app.ActiveDocument
>     'I NEED TO SET THE TO AND SUBJECT LINES HERE
>     app.ActiveDocument.SendMail

>     doc.Close
>     Set doc = Nothing
>     app.Quit
>     Set app = Nothing



Wed, 17 Mar 2004 03:39:49 GMT  
 Set and Email's To and Subject Fields
right,
but this attaches the RTF as a file instead of the contents of the RTF as
the contents of the email message.

thanks,
allen


Quote:
> Hi Allen,

> Look up in help: SendObject
> Goes like this:

> DoCmd.SendObject acSendReport, "MyReportName", _


>     Subject:="This is your subject", _
>     Messagetext:="Goodday," & vbr & "This is a line" & vbCr & "Kind
regards"

> Kind regards,
> Perry



> > hi,
> > how do i programatically set the TO and SUBJECT fields of a Word email.
I
> > am using the contents of an RTF created from an access report as the
> > contents of the email.  thanks in advance

> > This is what i have so far:

> >     strAttachmentName = "c:\temp\Wash-" & Format(Date, "mmddyy") &
".txt"
> >     'output the report to a text file
> >     DoCmd.OutputTo acOutputReport, strDocName, acFormatRTF,
> > strAttachmentName

> >     Dim app As New Word.Application
> >     Dim doc As Word.Document

> >     app.Documents.Open strAttachmentName
> >     app.Options.SendMailAttach = False
> >     Set doc = app.ActiveDocument
> >     'I NEED TO SET THE TO AND SUBJECT LINES HERE
> >     app.ActiveDocument.SendMail

> >     doc.Close
> >     Set doc = Nothing
> >     app.Quit
> >     Set app = Nothing



Wed, 17 Mar 2004 20:58:29 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Insert Field Value In Email Subject Line

2. Can't Preview Subject field

3. Accessing a File's comments or subject field

4. Setting the 'From' field

5. Deleting 'Set Fields'

6. inserting date within email body/subject line

7. Override field's caption set in table def

8. How to set field's format using DAO

9. Changing a field's default setting.

10. Word as email editor and seting subject

11. Save email on drive according to the subject

12. Get email Subject titles using VBA

 

 
Powered by phpBB® Forum Software