Outlook Function help

J

JC

Help new at functions-
Have
..Form![e-mailAddress], "Medco Finance Contracts Admin", "Manual Billing
Request. Adjustment Form", "Please review the attached document, Approve or
Reject by Email. Please email Medco Finance Contracts Admin the revised
Form." & Chr(10) & Chr(10) & "Thank you!" & Chr(10) & Chr(10) & "Adjustment
Administrator" & Chr(10) & Chr(10), "Billing Request Adjustment",
"S:\Finance\FISD\Adjustments\Snapshots\data.snp", "Approved; Rejected", 2,
True
End Sub

Function fctnOutlook(Optional FromAddr, Optional Addr, Optional CC, Optional
BCC, _
Optional Subject, Optional MessageText, Optional Categories, Optional
AttachmentPath, Optional Vote As String = vbNullString, _
Optional Urgency As Byte = 1, Optional EditMessage As Boolean = True)


Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

'Set StrCC = [Form]![e_mailAddress]
'Set ActiveControl = e_mailAddress
'Me.ActiveControl = e_mailAddress
'Set olCC = [Approver].Form![e-mailAddress]
'Set olCC = [Approver].Form![e-mailAddress]

With objOutlookMsg
If Not IsMissing(FromAddr) Then
.SentOnBehalfOfName = FromAddr
End If

If Not IsMissing(Addr) Then
Set objOutlookRecip = .Recipients.Add(Addr)
objOutlookRecip.Type = olTo
End If

If Not IsMissing(CC) Then
Set objOutlookRecip = .Recipients.Add(CC)
objOutlookRecip.Type = olCC

End If

If Not IsMissing(BCC) Then
Set objOutlookRecip = .Recipients.Add(BCC)
objOutlookRecip.Type = olBCC
End If

If Not IsMissing(Subject) Then
.Subject = Subject
End If

If Not IsMissing(MessageText) Then
.Body = MessageText
End If

If Not IsMissing(Categories) Then
.Categories = Categories
End If

If Not IsMissing(AttachmentPath) Then
'Check file exists before attaching!
If Len(Dir(AttachmentPath)) > 0 Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
Else
MsgBox "Attachment not found.", vbExclamation
End If
End If

If IsNull(Vote) = False Then
.VotingOptions = Vote
End If

Select Case Urgency
Case 2
.Importance = olImportanceHigh
Case 0
.Importance = olImportanceLow
Case Else
.Importance = olImportanceNormal
End Select

For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

If EditMessage Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing

End Function

need to specify form link for field in form for cc option
[Approver].Form![e-mailAddress] anyone have any ideas.
 
J

JC

Changed code to and I now can generate one e-mail address code for outlook ;
fails
for multiple recipiets
Private Sub CmdSendEmail_Click()
fctnOutlook , Me.e_mailAddress, Me.e_mailAddress, "Medco Finance Contracts
Admin", "Manual Billing Request. Adjustment Form", "Please review the
attached document, Approve or Reject by Email. Please email Medco Finance
Contracts Admin the revised Form." & Chr(10) & Chr(10) & "Thank you!" &
Chr(10) & Chr(10) & "Adjustment Administrator" & Chr(10) & Chr(10), "Billing
Request Adjustment", "S:\Finance\FISD\Adjustments\Snapshots\data.snp",
"Approved; Rejected", 2, True
End Sub

Function fctnOutlook(Optional FromAddr, Optional Addr, Optional CC, Optional
BCC, _
Optional Subject, Optional MessageText, Optional Categories, Optional
AttachmentPath, Optional Vote As String = vbNullString, _
Optional Urgency As Byte = 1, Optional EditMessage As Boolean = True)


Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim STRcc As String


Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

'Set StrCC = [Form]![e_mailAddress]
'Set ActiveControl = e_mailAddress
'Me.ActiveControl = e_mailAddress
'Set olCC = [Approver].Form![e-mailAddress]
'Set olCC = Me.e_mailAddress
STRcc = Me.e_mailAddress


JC said:
Help new at functions-
Have
.Form![e-mailAddress], "xxxx", "Manual Billing
Request. Adjustment Form", "Please review the attached document, Approve or
Reject by Email. Please email xxxx Admin the revised
Form." & Chr(10) & Chr(10) & "Thank you!" & Chr(10) & Chr(10) & "Adjustment
Administrator" & Chr(10) & Chr(10), "Billing Request Adjustment",
"S:\Finance\FISD\Adjustments\Snapshots\data.snp", "Approved; Rejected", 2,
True
End Sub

Function fctnOutlook(Optional FromAddr, Optional Addr, Optional CC, Optional
BCC, _
Optional Subject, Optional MessageText, Optional Categories, Optional
AttachmentPath, Optional Vote As String = vbNullString, _
Optional Urgency As Byte = 1, Optional EditMessage As Boolean = True)


Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

'Set StrCC = [Form]![e_mailAddress]
'Set ActiveControl = e_mailAddress
'Me.ActiveControl = e_mailAddress
'Set olCC = [Approver].Form![e-mailAddress]
'Set olCC = [Approver].Form![e-mailAddress]

With objOutlookMsg
If Not IsMissing(FromAddr) Then
.SentOnBehalfOfName = FromAddr
End If

If Not IsMissing(Addr) Then
Set objOutlookRecip = .Recipients.Add(Addr)
objOutlookRecip.Type = olTo
End If

If Not IsMissing(CC) Then
Set objOutlookRecip = .Recipients.Add(CC)
objOutlookRecip.Type = olCC

End If

If Not IsMissing(BCC) Then
Set objOutlookRecip = .Recipients.Add(BCC)
objOutlookRecip.Type = olBCC
End If

If Not IsMissing(Subject) Then
.Subject = Subject
End If

If Not IsMissing(MessageText) Then
.Body = MessageText
End If

If Not IsMissing(Categories) Then
.Categories = Categories
End If

If Not IsMissing(AttachmentPath) Then
'Check file exists before attaching!
If Len(Dir(AttachmentPath)) > 0 Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
Else
MsgBox "Attachment not found.", vbExclamation
End If
End If

If IsNull(Vote) = False Then
.VotingOptions = Vote
End If

Select Case Urgency
Case 2
.Importance = olImportanceHigh
Case 0
.Importance = olImportanceLow
Case Else
.Importance = olImportanceNormal
End Select

For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

If EditMessage Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing

End Function

need to specify form link for field in form for cc option
[Approver].Form![e-mailAddress] anyone have any ideas.
 
M

Michael Bauer [MVP - Outlook]

Look at the form and how the control is named. The naming convention
(record![field]) is for SQL. For forms you would write Form.Fieldname.

--
Best regards
Michael Bauer - MVP Outlook
Synchronize Outlook Categories:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Mon, 28 Jan 2008 11:22:13 -0800 schrieb JC:
Help new at functions-
Have
.Form![e-mailAddress], "Medco Finance Contracts Admin", "Manual Billing
Request. Adjustment Form", "Please review the attached document, Approve or
Reject by Email. Please email Medco Finance Contracts Admin the revised
Form." & Chr(10) & Chr(10) & "Thank you!" & Chr(10) & Chr(10) & "Adjustment
Administrator" & Chr(10) & Chr(10), "Billing Request Adjustment",
"S:\Finance\FISD\Adjustments\Snapshots\data.snp", "Approved; Rejected", 2,
True
End Sub

Function fctnOutlook(Optional FromAddr, Optional Addr, Optional CC, Optional
BCC, _
Optional Subject, Optional MessageText, Optional Categories, Optional
AttachmentPath, Optional Vote As String = vbNullString, _
Optional Urgency As Byte = 1, Optional EditMessage As Boolean = True)


Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

'Set StrCC = [Form]![e_mailAddress]
'Set ActiveControl = e_mailAddress
'Me.ActiveControl = e_mailAddress
'Set olCC = [Approver].Form![e-mailAddress]
'Set olCC = [Approver].Form![e-mailAddress]

With objOutlookMsg
If Not IsMissing(FromAddr) Then
.SentOnBehalfOfName = FromAddr
End If

If Not IsMissing(Addr) Then
Set objOutlookRecip = .Recipients.Add(Addr)
objOutlookRecip.Type = olTo
End If

If Not IsMissing(CC) Then
Set objOutlookRecip = .Recipients.Add(CC)
objOutlookRecip.Type = olCC

End If

If Not IsMissing(BCC) Then
Set objOutlookRecip = .Recipients.Add(BCC)
objOutlookRecip.Type = olBCC
End If

If Not IsMissing(Subject) Then
.Subject = Subject
End If

If Not IsMissing(MessageText) Then
.Body = MessageText
End If

If Not IsMissing(Categories) Then
.Categories = Categories
End If

If Not IsMissing(AttachmentPath) Then
'Check file exists before attaching!
If Len(Dir(AttachmentPath)) > 0 Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
Else
MsgBox "Attachment not found.", vbExclamation
End If
End If

If IsNull(Vote) = False Then
.VotingOptions = Vote
End If

Select Case Urgency
Case 2
.Importance = olImportanceHigh
Case 0
.Importance = olImportanceLow
Case Else
.Importance = olImportanceNormal
End Select

For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

If EditMessage Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing

End Function

need to specify form link for field in form for cc option
[Approver].Form![e-mailAddress] anyone have any ideas.
 
M

Michael Bauer [MVP - Outlook]

That mess is really hard to read. The first four arguments for the function
are:
- FromAdr
- Addr
- CC
- BCC

Now look at how you're calling the function; you pass:
- Empty
- e_mailAddress
- e_mailAddress (again)
- "Medco Finance..." (that's no address at all, so you can't add that to the
recipients object)

If you'd work with variables instead of passing all the text in one line you
(and others) could read your code easier.

--
Best regards
Michael Bauer - MVP Outlook
Synchronize Outlook Categories:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Mon, 28 Jan 2008 11:37:01 -0800 schrieb JC:
Changed code to and I now can generate one e-mail address code for outlook ;
fails
for multiple recipiets
Private Sub CmdSendEmail_Click()
fctnOutlook , Me.e_mailAddress, Me.e_mailAddress, "Medco Finance Contracts
Admin", "Manual Billing Request. Adjustment Form", "Please review the
attached document, Approve or Reject by Email. Please email Medco Finance
Contracts Admin the revised Form." & Chr(10) & Chr(10) & "Thank you!" &
Chr(10) & Chr(10) & "Adjustment Administrator" & Chr(10) & Chr(10), "Billing
Request Adjustment", "S:\Finance\FISD\Adjustments\Snapshots\data.snp",
"Approved; Rejected", 2, True
End Sub

Function fctnOutlook(Optional FromAddr, Optional Addr, Optional CC, Optional
BCC, _
Optional Subject, Optional MessageText, Optional Categories, Optional
AttachmentPath, Optional Vote As String = vbNullString, _
Optional Urgency As Byte = 1, Optional EditMessage As Boolean = True)


Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim STRcc As String


Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

'Set StrCC = [Form]![e_mailAddress]
'Set ActiveControl = e_mailAddress
'Me.ActiveControl = e_mailAddress
'Set olCC = [Approver].Form![e-mailAddress]
'Set olCC = Me.e_mailAddress
STRcc = Me.e_mailAddress


JC said:
Help new at functions-
Have
.Form![e-mailAddress], "xxxx", "Manual Billing
Request. Adjustment Form", "Please review the attached document, Approve or
Reject by Email. Please email xxxx Admin the revised
Form." & Chr(10) & Chr(10) & "Thank you!" & Chr(10) & Chr(10) & "Adjustment
Administrator" & Chr(10) & Chr(10), "Billing Request Adjustment",
"S:\Finance\FISD\Adjustments\Snapshots\data.snp", "Approved; Rejected", 2,
True
End Sub

Function fctnOutlook(Optional FromAddr, Optional Addr, Optional CC, Optional
BCC, _
Optional Subject, Optional MessageText, Optional Categories, Optional
AttachmentPath, Optional Vote As String = vbNullString, _
Optional Urgency As Byte = 1, Optional EditMessage As Boolean = True)


Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

'Set StrCC = [Form]![e_mailAddress]
'Set ActiveControl = e_mailAddress
'Me.ActiveControl = e_mailAddress
'Set olCC = [Approver].Form![e-mailAddress]
'Set olCC = [Approver].Form![e-mailAddress]

With objOutlookMsg
If Not IsMissing(FromAddr) Then
.SentOnBehalfOfName = FromAddr
End If

If Not IsMissing(Addr) Then
Set objOutlookRecip = .Recipients.Add(Addr)
objOutlookRecip.Type = olTo
End If

If Not IsMissing(CC) Then
Set objOutlookRecip = .Recipients.Add(CC)
objOutlookRecip.Type = olCC

End If

If Not IsMissing(BCC) Then
Set objOutlookRecip = .Recipients.Add(BCC)
objOutlookRecip.Type = olBCC
End If

If Not IsMissing(Subject) Then
.Subject = Subject
End If

If Not IsMissing(MessageText) Then
.Body = MessageText
End If

If Not IsMissing(Categories) Then
.Categories = Categories
End If

If Not IsMissing(AttachmentPath) Then
'Check file exists before attaching!
If Len(Dir(AttachmentPath)) > 0 Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
Else
MsgBox "Attachment not found.", vbExclamation
End If
End If

If IsNull(Vote) = False Then
.VotingOptions = Vote
End If

Select Case Urgency
Case 2
.Importance = olImportanceHigh
Case 0
.Importance = olImportanceLow
Case Else
.Importance = olImportanceNormal
End Select

For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

If EditMessage Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing

End Function

need to specify form link for field in form for cc option
[Approver].Form![e-mailAddress] anyone have any ideas.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top