Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

E-mailing Fixed Width .txt File Through Access 1

Status
Not open for further replies.

KimH2000

Programmer
Apr 22, 2002
4
US
I have been trying to automate the process of e-mailing a fixed width text file using a particular set of specs. I can produce the txt file using TransferText acExportFixed. When I do this I get the file with the right specs but I have to e-mail it myself. I can e-mail a text file using SendObject, but unfortunately when I do this I cannot indicate which spec I want to use and the resulting file has borders around each field and record.

Does anyone know of a way to do both at the same time?

Thanks [ponytails]
 
Create your text file and then use this code to send it (if you're using Outlook - otherwise there have been posts with code for LotusNotes posted recently as well - beyond that, I can't be much help...)

Private Sub cmdSend_Click()
On Error GoTo DriverErr

Dim Recipient As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

Recipient = "You@Something.com"

With MailOutLook
.To = Recipient
.Subject = "SUBJECT LINE"
.Body = "INSERT MESSAGE TEXT"
.Attachments.Add "FILE PATH", olByValue, 1
.Send
End With

DriverExit:
On Error Resume Next
Set MailOutLook = Nothing
Set appOutLook = Nothing
Exit Sub

DriverErr:
MsgBox Err.Description
Resume DriverExit
End Sub
Kyle [pipe]
 
This worked great Kyle. Thank you so much. You're the best!

Kim [ponytails]
 
Hi,

Ive tried pasting this code in my access module and when i tried to run it i got a compile error. what have i missed? [pc3]
Adam [glasses]
 
Adam,

When I pasted Kyle's code into my code it didn't work at first either. I received a compile error on the line

Dim appOutLook As Outlook.Application

The error stated "User-defined type not defined." To correct this go into References and check the "Microsoft Outlook 8.0 Object Library" box. After I did this the code worked perfectly.

Hope this helps!
Kim [ponytails]

 
When trying to run this with i got a 'unexpected error MAPI could was unable to load information file PSRTPRX.DLL' is it because my refernece is to Microsoft Outlook 9.0?

Thanks [bigcheeks]
[pc3]
Adam [glasses]
 
Kim, glad I could help!

Adam, I guess it could be, I've only tried this code with 8.0 and 8.5, but I doubt it since it's not having an issue with the code per-se, but with one of the files that it's supposed to be reading. Go back into tools-->references and select the Outlook 9.0 reference, on the bottom it will give you the path of the file. Is the file name "PSRTPRX.DLL"? It should be "msoutl9.olb".
Which line do you get this error on?
Kyle [pc1]
 
The file the refrence is using is : 'msoutl9.olb'
Where the module crashes: '.Send'

It opens an 'empty' outlook window and seems to run the code then crashes on the sending of the e-mail.

Thanks for the help [thumbsup2]


[pc3]
Adam [glasses]
 
If you step throught the code it makes the note fills it out and then crashes when it's time to send it?

If you go into the code and type in MailOutLook and then a period (.) is "Send" in the drop-down?

Try comenting out the line:
"Set appOutLook = CreateObject("Outlook.Application")" Kyle [pc1]
 
Thanks for this help!!

1st the MailOutLook.Send is availiable on the menu.
2nd when i commented out the line above i recieved runtime error 9, object variable or with block variable not set.

Just a thought, on this machine i have outlook express & outlook 2000, could that be the error? i currently have outlook express set up to send e-mails and 2000 to look pretty [gorgeous]- not really its there because we are planning to move over to that system soon.

Thanks again !!!!!!!!
--[SadEyes]-> [pc3]
Adam [glasses]
 
That could be, if your Outlook 200 isn't set up to send mail yet, that would cause it to crash when you tell it to send. I don't know how to access the Outlook express items. Is there an 'Express' reference you have a chance to access? What about changing the 'Dim appOutLook As Outlook.Application' to:
'Dim appOutLook As Outlook...?' And see if there is an express object instead... Kyle [pc1]
 
Thanks for the help, i will have a play with the outlook function and see what i can get, i i figure it out [dazed] then i will post my findings here. [pc3]
Adam [glasses]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top