Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    TxAggie2000
    Guest

    Emailing Reports in other than Outlook Express ??

    I went on an interview for a new job working with Access databases. I would consider myself above average in knowledge of Access, but no where near what most of you are I'm sure. The prospective employer didn't know you could email reports straight from Access, so when I told him you could he was really interested. However, I have always done it with the simple command button wizard which pulls up Outlook Express. He asked me if you could use the software they use in his office called GroupWise (I believe).

    Do any of you know if you can use something other than a MS product?

    I'm posting this before I research it, so while I'm researching - I hope one of you all can help me out.

    Thank you!!!

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Emailing Reports in other than Outlook Express ??

    You're in luck because I have some code I saved from the Access-L List that does just that. Groupwise is a Novell e-mail program (I'm stuck with it at work) that is far less friendly than Outlook Express, and I can't guarantee this code because I haven't tried it. If you have trouble making it work, there's also a shareware Access program call SendMail_RPS available form http://www.charm.net/~rps/access which sends messages directly through an SMTP server rather than using MAPI.

    Here's the code I saved:

    Date: Fri, 29 Sep 2000 15:54:08 -0500
    From: Sherry Gay <Gay.Sherry@BASCO.COM>
    Subject: Sending e-mail directly to Groupwise

    I've worked hard on putting this code together and I'm posting it
    in the hopes that it will help some other poor soul out there
    who's having problems with the DoCmd.SendObject working
    with GroupWise. This doesn't support attaching reports, yet,
    but when I get that part figured out, I'll let you know.
    If you find any bugs in it, please let me know about them.
    My address is gay.sherry@basco.com

    This is to be placed in a module, with a call from the button code. . .

    oooooooooooooooooooooooooooooooooooooooooooooooooo oooo
    'Constructed by Sherry Gay and Dale Barrett
    'Help obtained from Bob Good, and many archive documents, as well as ndk Token documentation.
    'Briggs & Stratton Corporation, Murray, KY
    'September 2000

    'Provided only as a sample to use. It works here.

    'Notes:
    'You need to set a reference to the 'Groupware type library'.
    'If the stTo, stCc, or stBc are going to be for more than one person, then they need to be
    'strung together with ';'(semi-colons).

    'Here's a sample call:
    ' Call SendMail("79111; 61000; Barrett, Dale", , , "Game Tonight!", "What time are we going?")


    Option Compare Database
    Option Explicit

    Dim ogwCmdr As Object '(Groupwise Commander, it cannot be early bound)

    Public Sub SendMail(Optional stTo As String, Optional stCc As String, _
    Optional stBc As String, Optional stSubject As String, Optional stMsg As String)

    Dim objGroupWise As Object 'for the session
    Dim objAccount As GroupwareTypeLibrary.Account 'for the login
    Dim objWorkFolder As GroupwareTypeLibrary.Folder 'for the folder
    Dim objMessage As GroupwareTypeLibrary.Message 'for the message
    Dim MsgId As String 'ID of the message created

    Set objGroupWise =3D CreateObject("NovellGroupWareSession")
    Set objAccount =3D objGroupWise.Login
    Set objWorkFolder =3D objAccount.WorkFolder
    Set objMessage =3D objWorkFolder.Messages.Add("GW.MESSAGE.Mail", egwDraft)

    MsgId = objMessage.MessageID

    'start up the Groupwise Commander
    Set ogwCmdr = CreateObject("GroupwiseCommander")

    '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''
    'Pass the arguments so they can be executed.
    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''

    'show the message
    Call gwExecute("ItemOpen", MsgId)

    'put in the To
    If stTo <> "" Then
    If InStr(stTo, ";") > 0 Then
    Call ParseMultiples("TextSetTo", stTo, ";")
    Else
    Call gwExecute("TextSetTo", stTo)
    End If
    End If
    'put in the CC
    If stCc <> "" Then
    If InStr(stTo, ";") > 0 Then
    Call ParseMultiples("TextSetCC", stCc, ";")
    Else
    Call gwExecute("TextSetCC", stCc)
    End If
    End If
    'put in the BC
    If stBc <> "" Then
    If InStr(stTo, ";") > 0 Then
    Call ParseMultiples("TextSetBC", stBc, ";")
    Else
    Call gwExecute("TextSetBC", stBc)
    End If
    End If
    'put in the Subject
    If stSubject <> "" Then
    Call gwExecute("TextSetSubject", stSubject)
    End If
    'put in the Text
    If stMsg <> "" Then
    Call gwExecute("TextSetMessage", stMsg)
    End If

    Set ogwCmdr = Nothing

    End Sub
    '--------------------------------------------------------------------------
    Public Sub gwExecute(stField As String, stText As String)
    'this just concatenates and passes the tokens to the commander
    Dim sCommand As String
    Dim iReturn As Integer
    Dim sReturn As String

    Select Case stField
    Case "ItemOpen" 'because this Command doesn't have a boolean parameter
    sCommand = stField & "(" & Chr(34) & stText & Chr(34) & ")"
    iReturn = ogwCmdr.Execute(sCommand, sReturn)
    Case Else 'if I leave out the boolean, then I can't send it to more than one person
    sCommand = stField & "(" & Chr(34) & stText & Chr(34) & ";" & True & ")"
    iReturn = ogwCmdr.Execute(sCommand, sReturn)
    End Select

    End Sub
    '--------------------------------------------------------------------------
    Public Sub ParseMultiples(stFieldToPass As String, stTextToPass As String, stParseOnThis)
    'this is for use with stTo, stCC, stBC when they want it to go to more than one person in any field
    Dim stParsedText As String
    Dim bKeepGoing As Boolean

    bKeepGoing = True 'flag to get out of the loop

    'parse the fields
    Do
    If InStr(stTextToPass, stParseOnThis) = 0 Then
    bKeepGoing = False
    stParsedText = Trim(stTextToPass)
    Call gwExecute(stFieldToPass, stParsedText)
    Else
    stParsedText = Left(stTextToPass, InStr(stTextToPass, stParseOnThis) - 1)
    stParsedText = Trim(stParsedText)
    Call gwExecute(stFieldToPass, stParsedText)
    stTextToPass = Right(stTextToPass, Len(stTextToPass) - InStr(stTextToPass, stParseOnThis))
    End If
    Loop Until bKeepGoing = False
    End Sub
    Charlotte

  3. #3
    Star Lounger
    Join Date
    Feb 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Err, Emailing Reports in Outlook Express??

    I am just starting to play with Access to email. I use Outlook Express. When I use DoCmd.SendTo, an Outlook configuration wizard starts, rather than sending the mail to Outlook Express which is what I expected (hoped) would happen.

    So my question is, based on the thread subject, how to you send mail from Access to Outlook Express? Do I need to uninstall Outlook (that's a bit brutal isn't it)?

    Using Office97 SR2, Outlook Express via IE4

    Marty

  4. #4
    Star Lounger
    Join Date
    Feb 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Emailing Reports in other than Outlook Express ??

    Thanks, I got your code working no problems.
    However, the logon logs on to Outlook. I have never used Outlook before on this machine, so I don't know why it would be the default mail client (I use Outlook Express every day). However, once I configured Outlook all was well.

    So the question still stands: how do I send mail using Outlook Express?

    Any suggestions how I control "the default mail client"? Or how to enforce which mail program the message is sent to?

    Also, I am curious as to why you place the new message in the inbox of the mail program, and not the outbox?

    Thanks for your help
    Marty

  5. #5
    qriusjorj
    Guest

    Re: Emailing Reports in other than Outlook Express ??

    I just tried using the code that Bart posted, but I'm getting an error when I run the code. The problem area is in the SendMail function with these lines:

    '************************************************* ******
    'De boodschap zelf invullen.
    '************************************************* ******
    Set objMes = objMySes.Inbox.Messages.Add
    With objMes
    .Text = txtText
    .Subject = txtSubject
    End With

    I get an error right at the With statement telling me that the object variable or with variable is not set.

    Any ideas?
    Is it because I don't know Dutch?
    Thanks, Sam

  6. #6
    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: Emailing Reports in other than Outlook Express ??

    Hi Sam,
    How are you using Bart's code? I think it's a class module so you need to create an instance of an object of that type (clsMAPI). Either that or call the class_initialize code at the start of your function and the class_terminate code at the end.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  7. #7
    qriusjorj
    Guest

    Re: Emailing Reports in other than Outlook Express ??

    Oh, okay, I got it! That's great! Thanks, Rory.

    Man, I've been battling Kernel 32 errors when I use the DoCmd.SendObject method for years. Microsoft couldn't help me either. (Surprising?) So this code is very welcome code to me!

    Anyway, my problem was that I wasn't handling the code as a class module.

    Another question, however. What can I do to change the code to allow me to attach an object to the email? What I would like to do is attach a report in the Snapshot format. (I've been doing this with the SendObject method, but it generates too many errors on different users computers.)

    Any ideas?
    Sam

  8. #8
    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: Emailing Reports in other than Outlook Express ??

    Sam,
    To add an attachment you can add the following within the With objMes...End With:
    .Attachments.add source:=myAttachment
    where myattachment is either an object or a string returning the filename and path of the attachment.
    Heelemal goed. (I think that's Dutch?)
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  9. #9
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Emailing Reports in other than Outlook Express ??

    Rory,

    Helemaal goed is dutch indeed.
    You were also perfectly right about the code I posted being a class module.
    I am putting more and more general stuff in class modules. Works great and, if you document it a little, is very easy to use over and over again.
    Sorry about the Dutch comments. I will try to replace it with English comments (when I can find the time to do it, so it can take while).

  10. #10
    qriusjorj
    Guest

    Re: Emailing Reports in other than Outlook Express ??

    Thanks again, Rory.

    Can you believe I have another question, though?

    I would like to attach the active report to the email. (My report has a custom toolbar, with a command button that will run the code that will email the report.)

    To email the current report I was using the following code:
    Dim rptCurrentReport As Object
    Set rptCurrentReport = Screen.ActiveReport
    DoCmd.SendObject acSendReport, strReportName, acFormatSNP, strEmailTo,,, strSubject, strMessage,True

    And it worked great...on some computers!

    Anyway, you mentioned that with the attachment code you posted I could attach an object. I'm having a hard time figuring out how to do that. (I had no problem attaching a file with a file path though.)

    Here's what I'm working with:
    Set objMes = objMySes.Inbox.Messages.Add
    With objMes
    .Text = txtText
    .Subject = txtSubject
    .Attachments.Add Source:=Screen.ActiveReport
    End With

    But I get Error 13 (Type Mismatch) on the .Attachments line.

    Any ideas? Also, how do I specify that the report be sent in Snapshot format?

    Thanks, again!
    Sam

  11. #11
    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: Emailing Reports in other than Outlook Express ??

    Hi Sam,
    What email system are you using? I'm not sure if generic MAPI message objects use the same syntax as Outlook message attachments (which is what I was referring to.) I guess you'd need some code to save the report to snapshot format and then attach that file to the email.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  12. #12
    qriusjorj
    Guest

    Re: Emailing Reports in other than Outlook Express ??

    We're using MS Outlook. I suppose I will need to save as, and then attach. I just like to make things as concise as possible.

    Thanks for you help.
    Sam

  13. #13
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Emailing Reports in other than Outlook Express ??

    Don't worry about the Dutch, Bart. Fortunately, it isn't hard to read VB/VBA code regardless of the language, because the built-in stuff is in English.
    Charlotte

  14. #14
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Emailing Reports in other than Outlook Express ??

    Hi Sam,

    You are right.
    If you want to attach a file to an email, you first have to have a file. A report in Access isn't a file (yet).
    So first save the report as a file (word or excel) and then attach the file.

  15. #15
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Emailing Reports in other than Outlook Express ??

    We have Lotus Notes and I use Snapshot Viewer to send my access reports via email. You can view, print and electronically mail a report snapshot. It creats a file with a .snp ending and you can send it as an attachment with any email program. You can download Snapshot Viewer from http://office.microsoft.com/downloaddetails/snpvw80.htm
    It is free. The directions are included on how to use it - very easy. The only thing is, the person who you email the report to must have Snapshot viewer too. It is very simple to install.

Page 1 of 2 12 LastLast

Posting Permissions

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