Running A2003 in A2007 runtime

  • Thread starter Thread starter Bill
  • Start date Start date
Yes, it is a table value taken from a bound control and passed to the
troublesome code as a parameter. The "troublesome" code is in a
general module and receives all of the values pertinent to a fully
configured e-mail. Specifically:

Sub SendMessage(SendTO, SendCOPY, sendBCC, textSubject As String, textBody
As String, _
DisplayMsg As Boolean, AttachmentPath1, AttachmentPath2,
AttachmentPath3)

The values for SentTo, textSubject, textBody and AttachmentPath1
are ALL table values taken from bound controls on a form. The only
one of these 4 parameters that is giving problems is the last one,
AttachmentPath1. The other 3 parameters assign without any problem.

Bill
 
GOT IT!!!!!!!!!!!!!!!

I specified the data type of AttachmentPath1 in the Sub statement
and everything took off as intended.

I.e.,
Sub SendMessage(SendTO, SendCOPY, sendBCC, textSubject As String, _
textBody As String, DisplayMsg As Boolean, AttachmentPath1 As String, _
AttachmentPath2 As String, AttachmentPath3 As String)

Your prodding took me in the right direction, thanks ever so much.

Bill
 
Your prodding took me in the right direction, thanks ever so much.

Keep going....

Sub SendMessage(SendTO As String, SendCOPY As String, sendBCC As String,
textSubject As String, _
textBody As String, DisplayMsg As Boolean, AttachmentPath1 As String, _
AttachmentPath2 As String, AttachmentPath3 As String)

<g>
 
Oh Yes, I already did!


John W. Vinson said:
Keep going....

Sub SendMessage(SendTO As String, SendCOPY As String, sendBCC As String,
textSubject As String, _
textBody As String, DisplayMsg As Boolean, AttachmentPath1 As String, _
AttachmentPath2 As String, AttachmentPath3 As String)

<g>
 
Not completely out of the woods yet. I get an error message
at the .Send when I attempt to address the e-mail to more than
one recipient. It just might be a syntax issue, but I don't find
any HELP on the subject of the Resolve method, as used in
the current code (below):

srtTo is a string passed to the SendWithOutlook sub and is
coded: "(e-mail address removed), (e-mail address removed)"

I tried using the ";" as the delimiter, but it still doesn't work.
I hope this one is obvious to either of you Gina or John.

Bill

Option Compare Database
Option Explicit
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
' Create a Outlook application object, fill in the essential parts and send
the
' e-mail with Microsoft Outlook.
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

Sub SendWithOutlook(strTo As String, strSubject As String, strBody As
String, _
DisplayMsg As Boolean, strAttach As String)

Dim objOL As Outlook.Application
Dim objOLMsg As Outlook.MailItem
Dim objOLRecip As Outlook.Recipient

' Create the Outlook session.
Set objOL = CreateObject("Outlook.Application")

' Create the message.
Set objOLMsg = objOL.CreateItem(olMailItem)

With objOLMsg
' Who's it going to
Set objOLRecip = .Recipients.Add(strTo)
objOLRecip.Type = olTo

' Set the subject and body of the e-mail
.Subject = strSubject
.Body = strBody & vbCrLf & vbCrLf

' Add the one attachment if there is one
If Not IsNull(strAttach) Then .Attachments.Add (strAttach)

' Resolve each Recipient's name.
For Each objOLRecip In .Recipients
objOLRecip.Resolve
Next

' Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Send
End If

End With
Set objOL = Nothing
End Sub
 
Turns out I have to add the e-mail addresses one at a time:

' Who's it going to
strRecipAr = Split(strTo, ",")
For I = 0 To UBound(strRecipAr)
Set objOLRecip = .Recipients.Add(strRecipAr(I))
Next

Works as desired.

Thanks,
Bill
 
Bill,

Glad to help! Now, you can go have a cup of coffee and celebrate!

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

GOT IT!!!!!!!!!!!!!!!

I specified the data type of AttachmentPath1 in the Sub statement
and everything took off as intended.

I.e.,
Sub SendMessage(SendTO, SendCOPY, sendBCC, textSubject As String, _
textBody As String, DisplayMsg As Boolean, AttachmentPath1 As String, _
AttachmentPath2 As String, AttachmentPath3 As String)

Your prodding took me in the right direction, thanks ever so much.

Bill
 
Bill,

See... a little prodding goes a long way!

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

Turns out I have to add the e-mail addresses one at a time:

' Who's it going to
strRecipAr = Split(strTo, ",")
For I = 0 To UBound(strRecipAr)
Set objOLRecip = .Recipients.Add(strRecipAr(I))
Next

Works as desired.

Thanks,
Bill
 
The big lesson here is that whenever one inherits
code from afar, one should always inspect the
code to see if it conforms to good practices.

As for me, I never write a Sub without explicitly
declaring the data types of the parameters, even
if it can be Variant I declare it as such. Had I
inspected the Sub statements at the outset,
determined the context in which the parameters
were used and declared accordingly, I could
have saved us all a lot of screwing around.

Thanks again for your help and patience.

Bill
 
You're welcome, that's why we are here!

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

The big lesson here is that whenever one inherits
code from afar, one should always inspect the
code to see if it conforms to good practices.

As for me, I never write a Sub without explicitly
declaring the data types of the parameters, even
if it can be Variant I declare it as such. Had I
inspected the Sub statements at the outset,
determined the context in which the parameters
were used and declared accordingly, I could
have saved us all a lot of screwing around.

Thanks again for your help and patience.

Bill
 
Back
Top