PDA

View Full Version : Add Email Addresses to GroupWise 7 emails



Valavien
09-29-2008, 09:06 PM
Hi all,

I am an ultra novice and really have no idea. I can use access ok but I am lost when it comes to VBA. I wanted to look at it myself but I have no idea. I am needing to get a VBA book to learn the basics. In the meantime I was hoping that someone could help change some code that I have.

It's for payroll. Employees have deductions from their salary. The money is sent to the institution or charity, then a listing is created and sent so they know which employees have sent them money.

So far my access db will create emails in a GroupWise mail box called "Work in Progress". I then have to open each email and select an address from the address book, then send it. I was hoping to get the code to also add the email address for the institution. That way I can maintain the email addresses in access rather than in groupwise. The email addresses are stored in a table called "Deductions" and the field is called "Email".

Any help greatly appreciated and I hope this code helps others.

The code as of now:


Sub SendMail(DedId As String)
Dim oMessage As GroupwareTypeLibrary.Message
Dim oAddress As GroupwareTypeLibrary.Address
Dim oRecipient As GroupwareTypeLibrary.Recipient
Dim oAddr As GroupwareTypeLibrary.Addresses
Dim oAddBkE As GroupwareTypeLibrary.AddressBookEntry

Set oMessage = oMessages.Add


If (Not IsNull(rc.Fields("Email").Value)) And rc.Fields("Email").Value <> "" Then
Set oAddr = oAddBk.AddressBookEntries.Find("(Name MATCHES """ & rc.Fields("Vendor Name").Value & """)")
If oAddr.Count = 0 Then
oAddBk.AddressBookEntries.Add rc.Fields("Vendor Name").Value, "internet:" & rc.Fields("Email").Value, "NGW"
Set oAddr = Nothing
Set oAddr = oAddBk.AddressBookEntries.Find("(Name MATCHES """ & rc.Fields("Vendor Name").Value & """)")
End If

' Set oRecipient = oMessage.Recipients.Add(oAddr.Item(1))
' oRecipient.Resolve
End If

oMessage.Subject = Trim$(ConvertMessage(rcSettings.Fields("EmailSubject").Value) & " " & ConvertMessage(rc.Fields("SubjectAppend").Value))
If rc.Fields("SubjectAppend").Value <> "" And (Not IsNull(rc.Fields("SubjectAppend").Value)) Then
oMessage.BodyText = ConvertMessage(rc.Fields("SubjectAppend").Value) & Chr$(10) & Chr$(10) & _
ConvertMessage(rcSettings.Fields("EmailText").Value)
Else
oMessage.BodyText = ConvertMessage(rcSettings.Fields("EmailText").Value)
End If
oMessage.FromText = "QHHRMISU"

If rc.Fields("Value") <> 0 Then
oMessage.Attachments.Add rcSettings.Fields("DocumentPath").Value & "TI" & rc.Fields("ded-id").Value & ".rtf", egwFile, "Tax Invoice.rtf"
End If
With Application.FileSearch
.NewSearch
.LookIn = rcSettings.Fields("DocumentPath").Value
.Filename = "ded" & rc.Fields("Ded-id").Value & "-" & Format(rcSettings.Fields("Period").Value, "000") & ".0"
.FileType = msoFileTypeAllFiles
If .Execute(msoSortByFileName, msoSortOrderDescending, True) >= 1 Then
rcRpt.Fields("Attachment").Value = True
oMessage.Attachments.Add .FoundFiles(1), , "deductions.txt"
Else
rcRpt.Fields("Attachment").Value = False
End If
End With

oMessage.Refresh
Set oMessage = Nothing

End Sub