Use VBA to open a new email message and attach a file 
Author Message
 Use VBA to open a new email message and attach a file

Hi there,

I would like to be able to use VBA to open a new email message using the
default email client, add a recipient, a subject, some message body and
attach a file that is not the active document.

Is this possible?  Any suggestions?

Thanks

Paul



Wed, 07 Sep 2005 05:03:28 GMT  
 Use VBA to open a new email message and attach a file
Why not do all that directly from the e-mail program? Why do you absolutely
need to do the whole job totally from VBA?

Maybe if you tell us why you need this done the way you think it should be
done, we can come up with an alternative that might be easier and faster to
implement...



Quote:
> Hi there,

> I would like to be able to use VBA to open a new email message using the
> default email client, add a recipient, a subject, some message body and
> attach a file that is not the active document.

> Is this possible?  Any suggestions?

> Thanks

> Paul



Wed, 07 Sep 2005 05:41:22 GMT  
 Use VBA to open a new email message and attach a file
Hi JGM

Good point. I guess I got tunnel vision on what I see as the solution.

I have a document that is used to collect sensitive data with text boxes and
other controls. When the user finishes filling in the form they click a
button which collates the data, encrypts it, and writes it out to a text
file, and then resets the form to blank and closes it. At the moment the
user must then open their email program and attach the file and send it.
This form is continually going out to new people who have not used it before
as a corporate survey and many amazingly cannot find the file to send, or
send it to the wrong address or a multitude of other things. I am just
hoping to automate the process as much as possible.

Hope this helps.

Paul


Quote:
> Why not do all that directly from the e-mail program? Why do you
absolutely
> need to do the whole job totally from VBA?

> Maybe if you tell us why you need this done the way you think it should be
> done, we can come up with an alternative that might be easier and faster
to
> implement...



> > Hi there,

> > I would like to be able to use VBA to open a new email message using the
> > default email client, add a recipient, a subject, some message body and
> > attach a file that is not the active document.

> > Is this possible?  Any suggestions?

> > Thanks

> > Paul



Wed, 07 Sep 2005 06:04:37 GMT  
 Use VBA to open a new email message and attach a file
Do you know what e-mail application users have, or could each user be using
a different application, even Hotmail for that matter?

You can easily control Outlook from VBA, but if you are writing a procedure
that could call on different e-mail applications, then I  don't know if it
can be done. For example, I know some people who have not set up Outlook on
their machine because they use Yahoo or something else like that. Even if
you called Outlook on those people's machine it would not work because there
are no active e-mail account created in their Outlook.... while other use
Outlook Express, Netscape messenger... can one procedure talk to all these
applications, regardless of the application called?

If  all your intended users use Outlook, you could do the reverse, call Word
from Outlook, and when you are done, send the result.



Quote:
> Hi JGM

> Good point. I guess I got tunnel vision on what I see as the solution.

> I have a document that is used to collect sensitive data with text boxes
and
> other controls. When the user finishes filling in the form they click a
> button which collates the data, encrypts it, and writes it out to a text
> file, and then resets the form to blank and closes it. At the moment the
> user must then open their email program and attach the file and send it.
> This form is continually going out to new people who have not used it
before
> as a corporate survey and many amazingly cannot find the file to send, or
> send it to the wrong address or a multitude of other things. I am just
> hoping to automate the process as much as possible.

> Hope this helps.

> Paul



> > Why not do all that directly from the e-mail program? Why do you
> absolutely
> > need to do the whole job totally from VBA?

> > Maybe if you tell us why you need this done the way you think it should
be
> > done, we can come up with an alternative that might be easier and faster
> to
> > implement...



> > > Hi there,

> > > I would like to be able to use VBA to open a new email message using
the
> > > default email client, add a recipient, a subject, some message body
and
> > > attach a file that is not the active document.

> > > Is this possible?  Any suggestions?

> > > Thanks

> > > Paul



Wed, 07 Sep 2005 06:21:23 GMT  
 Use VBA to open a new email message and attach a file
Why not re-open the text file into Word, and use the
following code:

Options.SendMailAttach = True
ActiveDocument.SendMail
ActiveDocument.Close

Kathleen

Quote:
>-----Original Message-----
>Hi JGM

>Good point. I guess I got tunnel vision on what I see as
the solution.

>I have a document that is used to collect sensitive data
with text boxes and
>other controls. When the user finishes filling in the
form they click a
>button which collates the data, encrypts it, and writes
it out to a text
>file, and then resets the form to blank and closes it. At
the moment the
>user must then open their email program and attach the
file and send it.
>This form is continually going out to new people who have
not used it before
>as a corporate survey and many amazingly cannot find the
file to send, or
>send it to the wrong address or a multitude of other
things. I am just
>hoping to automate the process as much as possible.

>Hope this helps.

>Paul



>> Why not do all that directly from the e-mail program?
Why do you
>absolutely
>> need to do the whole job totally from VBA?

>> Maybe if you tell us why you need this done the way you
think it should be
>> done, we can come up with an alternative that might be
easier and faster
>to
>> implement...




>> > Hi there,

>> > I would like to be able to use VBA to open a new

email message using the
Quote:
>> > default email client, add a recipient, a subject,

some message body and

- Show quoted text -

Quote:
>> > attach a file that is not the active document.

>> > Is this possible?  Any suggestions?

>> > Thanks

>> > Paul

>.



Wed, 07 Sep 2005 06:27:39 GMT  
 Use VBA to open a new email message and attach a file
Thanks, that works.

Any way to prefill the recipient field?

Paul


Why not re-open the text file into Word, and use the
following code:

Options.SendMailAttach = True
ActiveDocument.SendMail
ActiveDocument.Close

Kathleen

Quote:
>-----Original Message-----
>Hi JGM

>Good point. I guess I got tunnel vision on what I see as
the solution.

>I have a document that is used to collect sensitive data
with text boxes and
>other controls. When the user finishes filling in the
form they click a
>button which collates the data, encrypts it, and writes
it out to a text
>file, and then resets the form to blank and closes it. At
the moment the
>user must then open their email program and attach the
file and send it.
>This form is continually going out to new people who have
not used it before
>as a corporate survey and many amazingly cannot find the
file to send, or
>send it to the wrong address or a multitude of other
things. I am just
>hoping to automate the process as much as possible.

>Hope this helps.

>Paul



>> Why not do all that directly from the e-mail program?
Why do you
>absolutely
>> need to do the whole job totally from VBA?

>> Maybe if you tell us why you need this done the way you
think it should be
>> done, we can come up with an alternative that might be
easier and faster
>to
>> implement...




>> > Hi there,

>> > I would like to be able to use VBA to open a new

email message using the
Quote:
>> > default email client, add a recipient, a subject,

some message body and

- Show quoted text -

Quote:
>> > attach a file that is not the active document.

>> > Is this possible?  Any suggestions?

>> > Thanks

>> > Paul

>.



Wed, 07 Sep 2005 07:03:18 GMT  
 Use VBA to open a new email message and attach a file
Paul

Yet another option is to use Microsoft CDO for NTS n.n Library (cdonts.dll)
to generate your smtp mail. It's not dependant upon any particular mail
client. Sorry I'm not sure where you can pick up some documentation on
this. It's quite widely used for Web stuff. But once you set a reference to
the library you can explore its object model through the VBA IDE's Object
Browser (F2). It's pretty straightforward!

I hope this helps + Cheers - Peter



Quote:
> Hi JGM

> Good point. I guess I got tunnel vision on what I see as the solution.

> I have a document that is used to collect sensitive data with text boxes
> and other controls. When the user finishes filling in the form they
> click a button which collates the data, encrypts it, and writes it out
> to a text file, and then resets the form to blank and closes it. At the
> moment the user must then open their email program and attach the file
> and send it. This form is continually going out to new people who have
> not used it before as a corporate survey and many amazingly cannot find
> the file to send, or send it to the wrong address or a multitude of
> other things. I am just hoping to automate the process as much as
> possible.

> Hope this helps.

> Paul



>> Why not do all that directly from the e-mail program? Why do you
> absolutely
>> need to do the whole job totally from VBA?

>> Maybe if you tell us why you need this done the way you think it should
>> be done, we can come up with an alternative that might be easier and
>> faster
> to
>> implement...



>> > Hi there,

>> > I would like to be able to use VBA to open a new email message using
>> > the default email client, add a recipient, a subject, some message
>> > body and attach a file that is not the active document.

>> > Is this possible?  Any suggestions?

>> > Thanks

>> > Paul



Wed, 07 Sep 2005 07:06:14 GMT  
 Use VBA to open a new email message and attach a file
I don't know of a way to prefill the recipient field
(maybe with Sendkeys?).  Note that the SendMail method
works through Microsoft Exchange.

Kathleen

Quote:
>-----Original Message-----
>Thanks, that works.

>Any way to prefill the recipient field?

>Paul



>Why not re-open the text file into Word, and use the
>following code:

>Options.SendMailAttach = True
>ActiveDocument.SendMail
>ActiveDocument.Close

>Kathleen
>>-----Original Message-----
>>Hi JGM

>>Good point. I guess I got tunnel vision on what I see as
>the solution.

>>I have a document that is used to collect sensitive data
>with text boxes and
>>other controls. When the user finishes filling in the
>form they click a
>>button which collates the data, encrypts it, and writes
>it out to a text
>>file, and then resets the form to blank and closes it. At
>the moment the
>>user must then open their email program and attach the
>file and send it.
>>This form is continually going out to new people who have
>not used it before
>>as a corporate survey and many amazingly cannot find the
>file to send, or
>>send it to the wrong address or a multitude of other
>things. I am just
>>hoping to automate the process as much as possible.

>>Hope this helps.

>>Paul



>>> Why not do all that directly from the e-mail program?
>Why do you
>>absolutely
>>> need to do the whole job totally from VBA?

>>> Maybe if you tell us why you need this done the way you
>think it should be
>>> done, we can come up with an alternative that might be
>easier and faster
>>to
>>> implement...




>>> > Hi there,

>>> > I would like to be able to use VBA to open a new
>email message using the
>>> > default email client, add a recipient, a subject,
>some message body and
>>> > attach a file that is not the active document.

>>> > Is this possible?  Any suggestions?

>>> > Thanks

>>> > Paul

>>.

>.



Wed, 07 Sep 2005 07:28:57 GMT  
 Use VBA to open a new email message and attach a file
Hi Paul,

See the article How to send an email from Word using VBA at:

http://www.mvps.org/word/FAQs/InterDev/SendMail.htm

Please respond to the newsgroups for the benefit of others who may be
interested.

Hope this helps
Doug Robbins - Word MVP

Quote:
> Thanks, that works.

> Any way to prefill the recipient field?

> Paul



> Why not re-open the text file into Word, and use the
> following code:

> Options.SendMailAttach = True
> ActiveDocument.SendMail
> ActiveDocument.Close

> Kathleen
> >-----Original Message-----
> >Hi JGM

> >Good point. I guess I got tunnel vision on what I see as
> the solution.

> >I have a document that is used to collect sensitive data
> with text boxes and
> >other controls. When the user finishes filling in the
> form they click a
> >button which collates the data, encrypts it, and writes
> it out to a text
> >file, and then resets the form to blank and closes it. At
> the moment the
> >user must then open their email program and attach the
> file and send it.
> >This form is continually going out to new people who have
> not used it before
> >as a corporate survey and many amazingly cannot find the
> file to send, or
> >send it to the wrong address or a multitude of other
> things. I am just
> >hoping to automate the process as much as possible.

> >Hope this helps.

> >Paul



> >> Why not do all that directly from the e-mail program?
> Why do you
> >absolutely
> >> need to do the whole job totally from VBA?

> >> Maybe if you tell us why you need this done the way you
> think it should be
> >> done, we can come up with an alternative that might be
> easier and faster
> >to
> >> implement...




> >> > Hi there,

> >> > I would like to be able to use VBA to open a new
> email message using the
> >> > default email client, add a recipient, a subject,
> some message body and
> >> > attach a file that is not the active document.

> >> > Is this possible?  Any suggestions?

> >> > Thanks

> >> > Paul

> >.



Wed, 07 Sep 2005 07:37:29 GMT  
 Use VBA to open a new email message and attach a file
Hi Doug, Thanks for the link.

It works fine. The problem for me is that using the Routing Slip converts
the text file into a document so it can no longer be read by the import
routines at the data centre which rely on receiving the text file as it is.

Paul



Quote:
> Hi Paul,

> See the article "How to send an email from Word using VBA" at:

> http://www.mvps.org/word/FAQs/InterDev/SendMail.htm

> Please respond to the newsgroups for the benefit of others who may be
> interested.

> Hope this helps
> Doug Robbins - Word MVP


> > Thanks, that works.

> > Any way to prefill the recipient field?

> > Paul



> > Why not re-open the text file into Word, and use the
> > following code:

> > Options.SendMailAttach = True
> > ActiveDocument.SendMail
> > ActiveDocument.Close

> > Kathleen
> > >-----Original Message-----
> > >Hi JGM

> > >Good point. I guess I got tunnel vision on what I see as
> > the solution.

> > >I have a document that is used to collect sensitive data
> > with text boxes and
> > >other controls. When the user finishes filling in the
> > form they click a
> > >button which collates the data, encrypts it, and writes
> > it out to a text
> > >file, and then resets the form to blank and closes it. At
> > the moment the
> > >user must then open their email program and attach the
> > file and send it.
> > >This form is continually going out to new people who have
> > not used it before
> > >as a corporate survey and many amazingly cannot find the
> > file to send, or
> > >send it to the wrong address or a multitude of other
> > things. I am just
> > >hoping to automate the process as much as possible.

> > >Hope this helps.

> > >Paul



> > >> Why not do all that directly from the e-mail program?
> > Why do you
> > >absolutely
> > >> need to do the whole job totally from VBA?

> > >> Maybe if you tell us why you need this done the way you
> > think it should be
> > >> done, we can come up with an alternative that might be
> > easier and faster
> > >to
> > >> implement...




> > >> > Hi there,

> > >> > I would like to be able to use VBA to open a new
> > email message using the
> > >> > default email client, add a recipient, a subject,
> > some message body and
> > >> > attach a file that is not the active document.

> > >> > Is this possible?  Any suggestions?

> > >> > Thanks

> > >> > Paul

> > >.



Wed, 07 Sep 2005 08:09:53 GMT  
 Use VBA to open a new email message and attach a file
Here's another one

    Dim ol As Outlook.Application
    Dim mi As Outlook.MailItem

    On Error GoTo OLNotRun
    Set ol = GetObject(, "Outlook.Application")
    Set mi = ol.CreateItem(olMailItem)

    With mi



        .Body = "Dear Sirs," & vbCr & _
            "This is the message" & vbCr & "Krgrds,"
        .Attachments.Add ActiveDocument.FullName, olByValue
        .Display
    End With
    Set ol = Nothing
    Exit Sub
OLNotRun:
    Set ol = CreateObject("Outlook.Application")
    Resume Next

Krgrds,
Perry



Quote:
> Hi Doug, Thanks for the link.

> It works fine. The problem for me is that using the Routing Slip converts
> the text file into a document so it can no longer be read by the import
> routines at the data centre which rely on receiving the text file as it
is.

> Paul



> > Hi Paul,

> > See the article "How to send an email from Word using VBA" at:

> > http://www.mvps.org/word/FAQs/InterDev/SendMail.htm

> > Please respond to the newsgroups for the benefit of others who may be
> > interested.

> > Hope this helps
> > Doug Robbins - Word MVP


> > > Thanks, that works.

> > > Any way to prefill the recipient field?

> > > Paul



> > > Why not re-open the text file into Word, and use the
> > > following code:

> > > Options.SendMailAttach = True
> > > ActiveDocument.SendMail
> > > ActiveDocument.Close

> > > Kathleen
> > > >-----Original Message-----
> > > >Hi JGM

> > > >Good point. I guess I got tunnel vision on what I see as
> > > the solution.

> > > >I have a document that is used to collect sensitive data
> > > with text boxes and
> > > >other controls. When the user finishes filling in the
> > > form they click a
> > > >button which collates the data, encrypts it, and writes
> > > it out to a text
> > > >file, and then resets the form to blank and closes it. At
> > > the moment the
> > > >user must then open their email program and attach the
> > > file and send it.
> > > >This form is continually going out to new people who have
> > > not used it before
> > > >as a corporate survey and many amazingly cannot find the
> > > file to send, or
> > > >send it to the wrong address or a multitude of other
> > > things. I am just
> > > >hoping to automate the process as much as possible.

> > > >Hope this helps.

> > > >Paul



> > > >> Why not do all that directly from the e-mail program?
> > > Why do you
> > > >absolutely
> > > >> need to do the whole job totally from VBA?

> > > >> Maybe if you tell us why you need this done the way you
> > > think it should be
> > > >> done, we can come up with an alternative that might be
> > > easier and faster
> > > >to
> > > >> implement...




> > > >> > Hi there,

> > > >> > I would like to be able to use VBA to open a new
> > > email message using the
> > > >> > default email client, add a recipient, a subject,
> > > some message body and
> > > >> > attach a file that is not the active document.

> > > >> > Is this possible?  Any suggestions?

> > > >> > Thanks

> > > >> > Paul

> > > >.



Wed, 07 Sep 2005 22:14:43 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. open a message file *.msg in outlook 2000 using vba

2. Automatically Attach a File to a New Mail Message

3. Trouble attaching file to email using MAPI control

4. Email Messages using VBA or Macros!!

5. script which send an email to an email adress, with file attached

6. make an HTML file the body of a new email message

7. Using VBA Automation to Open Word at the File Open Locatiion

8. Moving an attached outlook message into a Outlook MailItem object with VB/VBA

9. Can I access current email message from within email message

10. Saving open file and opening new file at a specified time of day

11. Opening a File Open window for file selection in VBA

12. Creating New Project2000 file using VBA?

 

 
Powered by phpBB® Forum Software