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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Outlook emails with attachments from Foxpro or other

Status
Not open for further replies.

trekker123

Programmer
Jun 6, 2003
11
0
0
US
Here is the overall picture:

1. In Foxpro or other app, put on the clipboad the addressee, subject, body of message, attached file location & name in the formate described below.

2. Run a Visual Basic script that parses the clipboard text, generates and email, populates the email and attaches one file (I haben't figured out ho to attach more than one file).

DISCLAIMER: I'm not the world's best programmer, but here is how I do it. You will probably have to play around with the code a bit.

My Foxpro app places on the clipboard:
STORE ;
"GENERIC "+;
LEFT("&CTCDIR"+REPLI(" ",61),61)+;
LEFT("filename.txt"+REPLI(" ",50),50)+;
LEFT("Email subject here"+repl(" ",25),25)+;
LEFT("outlook addressee"+REPLI(" ",60),60)+;
"This is the text in th eemail body."+;
REPL(" ",100) TO _CLIPTEXT
The RUN the compiled VB app

The VB code:
Option Explicit
Dim Mail_Which
Dim SuperName
Dim Directory
Dim Directory2
Dim Email_to
Dim Other_info
Dim Filename
Dim PRNFile
Dim XLSFile
Dim AreaName
Dim txtAreaName
Dim EmailBody
Dim Subject
Dim Unused

Private Sub Form_Load()

ElseIf Mail_Which = "GENERIC" Then
'Email the checkout file to the PM from 'Boss'
Unused = Trim(Mid(Clipboard.GetText(vbCFText), 9, 8))
Filename = Trim(Mid(Clipboard.GetText(vbCFText), 78, 50))
Directory = Trim(Mid(Clipboard.GetText(vbCFText), 17, 60)) + Filename
Filename = Trim(Mid(Clipboard.GetText(vbCFText), 78, 50))
Subject = Trim(Mid(Clipboard.GetText(vbCFText), 128, 25))
Email_to = Trim(Mid(Clipboard.GetText(vbCFText), 153, 60))
EmailBody = Trim(Mid(Clipboard.GetText(vbCFText), 213, 700))

'Put the same data on the form to confirm the
'clipboard text was parsed OK
txtDirectory.Text = Directory
txtSuperName.Text = Filename
txtEmail_to.Text = Email_to
Call cmd_GENERIC_Click
ElseIf Mail_Which = "other possible formats" Then
yada yada yada
End If

'Remark the next statement and run the program, then
'you can see the form and the data that was parsed into
'the variables and placed on the form
Call Cmd_quit_Click

Private Sub cmd_GENERIC_Click()
'Mail the DOC files
Dim My01App, MyItem As Object
Dim MyAttachments, O1MailItem
Dim FileDate As Date
Set My01App = CreateObject("Outlook.Application")
Set MyItem = My01App.CreateItem(O1MailItem)
MyItem.Subject = Subject
MyItem.Body = Chr(11) + EmailBody + _
Chr(11) + Chr(11) + "sent: " & Now()
Set MyAttachments = MyItem.Attachments
MyAttachments.Add Directory, , 1
MyItem.to = Email_to
'review the email before sending it
MyItem.Display
'There is a command, or maybe delete the prior line
'send send te email without reviewing it.

End Sub

Private Sub Cmd_quit_Click()
Unload frmCTCemail
End Sub
 
From your description, it seems as though Foxpro is doing its job well for you already by passing:
1. the email Attachment filename
2. Subject text
3. Recipient's email address
4. email body text
to the clipboard.

So it seems as though your problem is either finding the appropriate format to use to pass multiple file attachments (non-Foxpro issue) or it is getting VB to work.

If that is true then you might be better served by posting your question on the
Visual Basic(Microsoft): Version 5 & 6 Forum
forum222

Good Luck,


JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top