Author |
|
Guest Guest Group
Joined: 10 November 2003
Online Status: Online Posts: 262
|
Posted: 29 November 2005 at 6:45pm | IP Logged
|
|
|
Hi,
I skimmed through the Q&A and most of the attachment questions are for saving/downloading an attachment.
How do I actually attach a file and send to a specified e-mail (receiver)?
Here's what i have:
'Called when user is locating an attachment file from local hard drive
'
Private Sub myDir_Change()
myFile.Path = myDir.Path
Call myModule.ShowFileList(myFile.Path)
End Sub
'The user selects a file to attach, the path is then sent to a textbox value.
Private Sub myFile_Click()
myPath = myFile.Path & myFile.List(myFile.ListIndex)
txtAttach.Text = myPath
End Sub
so now that the txtAttach.Text is, say "c:\...\Desktop\MountView.JPG", how do I attach this object to my sendEmail sub? (send sub is as follows)
Public Sub sendEmail()
Dim oMsg As MailBee.Message
With frmMain
pubSender = .txtFrom.Text
pubReceiver = .txtTo.Text
pubSubject = .txtSubj.Text
pubMessage = .txtBody.Text
End With
'New connection to SQL Server
Set sqlConn = CreateObject("ADODB.Connection")
'Connection string to SQL Server
'Open SQL Server DB connection
With sqlConn
.ConnectionString = "DRIVER=SQL Server;UID=xxx;PWD=xxx;DATABASE=xxx;SERVER=xxx" 'grf1s006
.CommandTimeout = 10
.ConnectionTimeout = 10
.CursorLocation = adUseServer
.Mode = adModeReadWrite
.Open
qstr = "INSERT INTO email_notifications (date_raised, email_to, email_from, email_subject, email_body, area, sent_flag) "
qstr = qstr & "VALUES ('" & Now() & "', '" & pubReceiver & "', '" & pubSender & "', '" & pubSubject & "', '" & pubMessage & "', 'RMA', '0') "
sqlConn.Execute qstr
End With
sqlConn.Close
Set sqlConn = Nothing
End Sub
The EmailNotification table is basically a StoredProcedure that executes every 5 minutes and sends e-mail out to receiver's e-mail. How do I send an object (since table doesn't take in an object/attachment).
Thanks...
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 30 November 2005 at 10:28am | IP Logged
|
|
|
It's not actually clear how exactly the mail being sent. Your code just puts a record in email_notifications table. But what does your stored procedure actually do? Does it use MailBee.SMTP to send mail? Could you please provide the stored procedure sample code?
If you're using MailBee.SMTP within a stored procedure, you can actually attach a file using SMTP.AddAttachment method call within this procedure. In this case, you should previously put an attachment filepath into email_notifications table in order to obtain the path to the file to be attached within the stored procedure.
You can find the example of using MailBee.SMTP object in MS SQL Server stored procedure in the following topic:
smtp from extended stored proc.
Regards,
Alex
|
Back to Top |
|
|