This one has me stumped. I am using Access 2003 and have successfully used this code in other DBs to send emails via Lotus Notes. I have modifed my original code for a new database and I am getting a: "ByRef Argument Type Mismatch" Compile Error. I cannot seem to find the cause.
The HoldSML is what is highlighted when I debug and the compile error appears. I tried removing the HoldSML completely, and when I compiled: HoldMC was highlighted. So I know it's not specific to HoldSML.
This is the code I am using to send the email:
Any insight / direction / input would be appreciated. Thank you.
:banghead:
Code:
Option Compare Database
Option Explicit
Sub ShiftEmailSend()
Dim stToShift As String
Dim HoldFBR As String
Dim HoldMF As String
Dim HoldINS As String
Dim HoldFin As String
Dim HoldBDEvents5 As String
Dim HoldFBT As String
Dim HoldUBF As String
Dim HoldFF As String
Dim HoldRF As String
Dim HoldMC As String
Dim HoldSML As String
Dim HoldSMR As String
Dim HoldBDEvents10 As String
Dim HoldComments As String
Dim HoldZone1Title As String
Dim HoldZone2Title As String
Dim HoldZone3Title As String
Dim HoldCommentsTitle As String
Dim HoldBDEvents5Title As String
Dim HoldBDEvents10Title As String
Dim HoldHeadingTitle As String
HoldHeadingTitle = " ANDON" & vbTab & "SAP ENTRY" & vbCrLf
HoldZone1Title = "Zone 1" & vbCrLf
HoldFBR = "FBR: " & Forms!frmShiftReport!FBRAndon.Value & vbTab & Forms!frmShiftReport!FBRSAP.Value & vbCrLf
HoldMF = "MF: " & Forms!frmShiftReport!MFAndon.Value & vbTab & Forms!frmShiftReport!MFSAP.Value & vbCrLf
HoldINS = "Install: " & Forms!frmShiftReport!InstallAndon.Value & vbTab & Forms!frmShiftReport!InstallSAP.Value & vbCrLf
HoldFin = "Final: " & Forms!frmShiftReport!FinalAndon.Value & vbTab & Forms!frmShiftReport!FinalSAP.Value & vbCrLf
HoldBDEvents5Title = "BD Events > 5 mins" & vbCrLf
HoldBDEvents5 = Forms!frmShiftReport!BDEvents5.Value & vbCrLf & vbCrLf
HoldZone2Title = "Zone2" & vbCrLf
HoldFBT = "FBT: " & Forms!frmShiftReport!FBTAndon.Value & vbTab & Forms!frmShiftReport!FBTSAP.Value & vbCrLf
HoldUBF = "UBF: " & Forms!frmShiftReport!UBFAndon.Value & vbTab & Forms!frmShiftReport!UBFSAP.Value & vbCrLf
HoldFF = "FF: " & Forms!frmShiftReport!FFAndon.Value & vbTab & Forms!frmShiftReport!FFSAP.Value & vbCrLf
HoldRF = "RF: " & Forms!frmShiftReport!RFAndon.Value & vbTab & Forms!frmShiftReport!RFSAP.Value & vbCrLf
HoldMC = "MC: " & Forms!frmShiftReport!MCAndon.Value & vbTab & Forms!frmShiftReport!MCSAP.Value & vbCrLf
HoldSML = "SML: " & Forms!frmShiftReport!SMLAndon.Value & vbTab & Forms!frmShiftReport!SMLSAP.Value & vbCrLf
HoldSMR = "SMR: " & Forms!frmShiftReport!SMRAndon.Value & vbTab & Forms!frmShiftReport!SMRSAP.Value & vbCrLf
HoldBDEvents10Title = "BD Events > 10 mins" & vbCrLf
HoldBDEvents10 = Forms!frmShiftReport!BDEvents10.Value & vbCrLf & vbCrLf
HoldZone3Title = "Zone 3" & vbCrLf
HoldCommentsTitle = "Comments" & vbCrLf
HoldComments = Forms!frmShiftReport!Comments.Value
stToShift = "Manufacturing Maintenance Email"
Call SendShiftNotesMail("MTC Shift Notes", stToShift, HoldHeadingTitle, HoldZone1Title, HoldFBR, HoldMF, HoldINS, HoldFin, _
HoldBDEvents5Title, HoldBDEvents5, HoldZone2Title, HoldFBT, HoldUBF, HoldFF, HoldRF, HoldMC, [B][COLOR=red]H[/COLOR][COLOR=red]oldSML[/COLOR][/B], HoldSMR, HoldBDEvents10Title, _
HoldBDEvents10, HoldZone3Title, HoldCommentsTitle, HoldComments, True)
End Sub
The HoldSML is what is highlighted when I debug and the compile error appears. I tried removing the HoldSML completely, and when I compiled: HoldMC was highlighted. So I know it's not specific to HoldSML.
This is the code I am using to send the email:
Code:
'This public sub will send a mail to the recipient including the body text.
'Requires that notes client is installed on the system.
Public Sub SendShiftNotesMail(Subject As String, Recipient As String, FBR As String, MF As String, INS As String, Fin As String, _
BDEvents5 As String, FBT As String, UBF As String, FF As String, RF As String, MC As String, SML As String, SMR As String, _
BDEvents10 As String, Comments As String, SaveIt As Boolean)
'Set up the objects required for Automation into lotus notes
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'The current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string or using above password you can use other mailboxes.
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
'Open the mail database in notes
Set Maildb = Session.getdatabase("", MailDbName)
If Maildb.ISOPEN = True Then
'Already open for mail
Else
Maildb.openmail
End If
'Set up the new mail document
Set MailDoc = Maildb.createdocument
MailDoc.Form = "Memo"
MailDoc.sendto = Recipient
MailDoc.Subject = Subject
MailDoc.Body = FBR & vbCrLf & MF & vbCrLf & INS & vbCrLf & Fin & vbCrLf & BDEvents5 & vbCrLf & FBT & vbCrLf & _
UBF & vbCrLf & FF & vbCrLf & RF & vbCrLf & MC & vbCrLf & SML & vbCrLf & SMR & vbCrLf & BDEvents10 & vbCrLf & Comments
MailDoc.SaveMessageOnSend = SaveIt
'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
MailDoc.Send 0, Recipient
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub
Any insight / direction / input would be appreciated. Thank you.
:banghead: