PDA

View Full Version : Solved: Sending Email bases on Table Query



skaswani
12-24-2010, 02:11 AM
:banghead:

Using Access : 2007

Dear All,


Please review this code and help me to make some changes,




'Public Sub SendNotesMail(Subject As String, Attachment As String, Recipient1 As String, BodyText As String)
Public Sub SendNotesMail()
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 AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)


Set Session = CreateObject("Notes.NotesSession")

UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"

Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.IsOpen = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If


Dim recip(25) As Variant
Dim ccRecipient(25) As Variant

recip(0) = "sk@sajjad.com"
recip(1) = "sk2@sajjad.com "
ccRecipient(0) = "sk@sajjad.com"
ccRecipient(1) = "sk@sajjad.com"
Subject = "CDS - General Data Missing Information"
BodyText = "Dear All, Please find the attached file for CSD Collection A/c and fill the missing valued Information such as Case #, Service # , Name and Rank and Please send it on Urgent basis! Thanks "
Attachment = "c:\export\01132101343006.xls"

Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = recip
MailDoc.CopyTo = ccRecipient
MailDoc.Subject = Subject
MailDoc.Body = BodyText


MailDoc.SAVEMESSAGEONSEND = SaveIt


If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")

' MailDoc.CREATERICHTEXTITEM ("Attachment")
End If

MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
' MailDoc.Send 0, Recipient
MailDoc.Send , 0, MailDoc.sendto


Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub




what i want to do:
Send an Email through Lotus notes from a Access Table : EmailSetup

the table has :

BranchCode
FileLocation
Email1
Email2


what i need to do is to LOOP this table till EOF and send the files to respective Manager

Please Help me
Thankful

skaswani
12-24-2010, 06:04 AM
completed
thanks