Results 1 to 15 of 15
  1. #1
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA-EMail Syntax (97 SR2)

    I'm using the following code to automatically send an e-mail from my userform:

    Sub btnemail()
    Dim vsubject As Variant
    vsubject = ("This is a test.")
    Application.Dialogs(xlDialogSendMail).Show "me@mydomain.com", [vsubject]
    End Sub

    Does anyone know which of the nearly 30 arguments for this command will work for the body?

    I want to compose my e-mail based on controls in my form, then send it "automatically"...

    TYA
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA-EMail Syntax (97 SR2)

    FYI, i'm sending this to Netscape Mail, so any references to the Outlook OLE engine won't work.. (this isn't by choice of course...) <img src=/S/wink.gif border=0 alt=wink width=15 height=15>
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  3. #3
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: VBA-EMail Syntax (97 SR2)

    Hi Drk,
    As far as I'm aware none of the arguments is the body text. The SendMail method of a workbook certainly doesn't allow you to specify it.
    Sorry!
    Regards,
    Rory

    Microsoft MVP - Excel

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA-EMail Syntax (97 SR2)

    Hmm.. bummer..

    Can you think of another solution to this problem? <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Thanks!
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  5. #5
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: VBA-EMail Syntax (97 SR2)

    Um, use Outlook? <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    I don't know what sort of system Netscape mail is - if it's MAPI, then you should be able to do something comparable to what you would do with Outlook. Alternatively you could add your email body text as a cover page at the front of your spreadsheet?
    Regards,
    Rory

    Microsoft MVP - Excel

  6. #6
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA-EMail Syntax (97 SR2)

    Let's assume that it is MAPI... (I wouldn't be surprised if it weren't..) What method would I use to add a string to my e-mail body?
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  7. #7
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: VBA-EMail Syntax (97 SR2)

    You'd use something like:
    Set objMes = objMySes.Inbox.Messages.Add
    With objMes
    .Text = txtText
    .Subject = txtSubject
    End With
    where objMySes is a MAPI session. There's a full class module you can use in the Access forum written by Bart - just do a search on MAPI and you should find it.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  8. #8
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA-EMail Syntax (97 SR2)

    Wow.. that's really confusing with all the dutch in there... perhaps you have some pointers on how to use it?
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  9. #9
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA-EMail Syntax (97 SR2)

    This doesn't appear to be working...

    I've placed the class module posted by Bart into Module 1, even publicly declared a number of the statements... no go.

    There must be a way to add text to the body of a Netscape Mail e-mail programattically.. anyone have any ideas?
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  10. #10
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: VBA-EMail Syntax (97 SR2)

    Drk

    I don't know what class module you are referring to, but I don't think it belongs in module 1. In VBA, goto Insert and select Class module and try placing the code there (probably Class1).

    Hope that helps you along

    Andrew

  11. #11
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA-EMail Syntax (97 SR2)

    The module i'm referring to is <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Cat=&Board=acc&Number=14213&Search =true&Forum=acc&Words=Bart&Match=StarPost&Searchpa ge=0&Limit=25&Old=allposts&Main=1602>Here.</A>

    I keep getting 'variable not defined' errors... <img src=/S/nuts.gif border=0 alt=nuts width=15 height=15>
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  12. #12
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: VBA-EMail Syntax (97 SR2)

    Drk,

    Have you actually placed the code in a class module, and if so at what stage are you getting an error ?

    Andrwew

  13. #13
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA-EMail Syntax (97 SR2)

    I know i'm not doing it correctly...

    I've got that code in a new class module, then the following in my form code:

    Private Sub btnSend2Friend_Click()
    Set objMes = objMySes.Inbox.Messages.Add
    With objMes
    .Text = "This is some text."
    .Subject = "This is some subject"
    End With
    End Sub

    I know this isn't even close.. so how can I call the 'SendMail' function in my class module?
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  14. #14
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: VBA-EMail Syntax (97 SR2)

    Hi Drk,
    Once you've pasted the code into a class module you should rename the class module to clsMAPI (you can actually call it whatever you want, just remember to replace clsMAPI in the next bit of code with the name you've given the module) and then you can use something like:
    Private Sub btnSend2Friend_Click()
    Dim objMAPISession As New clsMAPI
    objMAPISession.SendMail "me@here.com", "Hello Rory", "Testing MAPI class"
    Set objMAPISession = Nothing
    End Sub
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  15. #15
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA-EMail Syntax (97 SR2)

    I'm getting the following error:

    Run-Time error '429':
    ActiveX component can't create object

    Set objMySes = CreateObject("MAPI.Session")

    Netscape Mail is MAPI Compliant, I've located this document: <A target="_blank" HREF=http://developer.netscape.com/docs/manuals/communicator/mapisupp.htm>Simple MAPI Compliance Spec</A> which outlines some particulars...

    Bearing this in mind, how can I modify the code to make it work?

    Thanks!
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •