T
Timmy
I am creating an Access 2002 program to generate an email based upon text
that was entered on a form, insert the auto signature, add the previous
message that was imported into a table, plus add any attachments.
1. How can I retrieve the auto-signature from outlook?
2. My trouble is when I am trying to add attachments to the beginning of
the message. Even though I enter a 1 (for position) in the add statement, it
still puts the attachments at the bottom. Any suggestions?
Here is my program:
Private Sub CreateEmail_Click()
'Using the forms entry fields, create an email message
Dim olApp As Outlook.Application
Dim olmessage As Outlook.MailItem
Dim olrecipients As Outlook.Recipient
Dim olattachments As Outlook.Attachment
Dim fname, dname As String
Dim syscode As String
Dim i, sp, ep, bl As Integer
Dim dbs As DAO.Database
Dim recset As DAO.Recordset
Set olApp = CreateObject("Outlook.Application")
Set olmessage = olApp.CreateItem(olMailItem)
With olmessage
..
..
..
'create message body
.Body = " " & EnterMessage & Chr(10) & Chr(10) &
"=========================" & Chr(10) & Chr(10) _
& Forms!InboxProcessingServiceOrderView!Contents _
& Chr(10) & Chr(10) & syscode
'add any attachments that have been selected
Set dbs = CurrentDb
Set recset = dbs.OpenRecordset("AttachFile2Mail")
If recset.RecordCount > 0 Then
recset.MoveFirst
Do While Not recset.EOF
fname = "\\Plwfs002\CMU\InternalDatabases\CMU\cms\attachments\"
& recset!AttachmentName
dname = recset!ActualName
Set olattachments = .Attachments.Add(fname, olByValue, 1, dname)
recset.MoveNext
Loop
recset.Close
End If
End With
olmessage.Display
Set dbs = Nothing
Set recset = Nothing
Set olrecipients = Nothing
Set olmessage = Nothing
Set olApp = Nothing
End Sub
that was entered on a form, insert the auto signature, add the previous
message that was imported into a table, plus add any attachments.
1. How can I retrieve the auto-signature from outlook?
2. My trouble is when I am trying to add attachments to the beginning of
the message. Even though I enter a 1 (for position) in the add statement, it
still puts the attachments at the bottom. Any suggestions?
Here is my program:
Private Sub CreateEmail_Click()
'Using the forms entry fields, create an email message
Dim olApp As Outlook.Application
Dim olmessage As Outlook.MailItem
Dim olrecipients As Outlook.Recipient
Dim olattachments As Outlook.Attachment
Dim fname, dname As String
Dim syscode As String
Dim i, sp, ep, bl As Integer
Dim dbs As DAO.Database
Dim recset As DAO.Recordset
Set olApp = CreateObject("Outlook.Application")
Set olmessage = olApp.CreateItem(olMailItem)
With olmessage
..
..
..
'create message body
.Body = " " & EnterMessage & Chr(10) & Chr(10) &
"=========================" & Chr(10) & Chr(10) _
& Forms!InboxProcessingServiceOrderView!Contents _
& Chr(10) & Chr(10) & syscode
'add any attachments that have been selected
Set dbs = CurrentDb
Set recset = dbs.OpenRecordset("AttachFile2Mail")
If recset.RecordCount > 0 Then
recset.MoveFirst
Do While Not recset.EOF
fname = "\\Plwfs002\CMU\InternalDatabases\CMU\cms\attachments\"
& recset!AttachmentName
dname = recset!ActualName
Set olattachments = .Attachments.Add(fname, olByValue, 1, dname)
recset.MoveNext
Loop
recset.Close
End If
End With
olmessage.Display
Set dbs = Nothing
Set recset = Nothing
Set olrecipients = Nothing
Set olmessage = Nothing
Set olApp = Nothing
End Sub