Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sending email from access - Reference Stephen Lebans code

2 views
Skip to first unread message

Irshad Alam

unread,
Aug 28, 2008, 4:58:03 AM8/28/08
to
I have used the code and dll files after downloading from Mr. Stephen Lebans
website for converting the report to pdf (which have also dynapdf.dll &
strstorage.dll) . The following code I used which worked perfectly :

Private Sub Label59_Click()
RepoToPdfWC
End Sub

Function RepoToPdfWC()
Dim blRet As Boolean
blRet = ConvertReportToPDF(Me.Text60, vbNullString,
"C:\WsImpFiles\MyClaimedPDF\" & "Job-" & Me.JobNo & "-ClaimRef." &
Me.ClaimRefNo.Value & ".PDF", False)
End Function

Note : Me.Text60 contains the report name

The above sucessfully converts to pdf and open the pdf into acrobat 5

I want to add more codes and edit on above to get my below requirement

1 It should not open the acrobat for preview
2. it should open outlook express 6 - new email message and attach the above
created pdf and according to below BUT should not send, so that I can have a
final view before sending :

Email as below :

From: = mirsh...@hotmail.com
To: = irshad...@ggcompany.com
CC: = naaeem...@ggcompany.com
Subject: = "Job-" & Me.JobNo & "-ClaimRef." & Me.ClaimRefNo.Value
Body = "Reference is made to subject claim, attached pls. find the claim
form as pdf"
Bodysecondline="Thanks"
Bodythirdline="Irshad"
AttachmentFile="C:\WsImpFiles\MyClaimedPDF\" & "Job-" & Me.JobNo &
"-ClaimRef." & Me.ClaimRefNo.Value & ".PDF"


Note2 : I am using Windows XP svcpack2 and outlook express 6 , ms office 2000

Please advice, it will help me to reduce job time of hours.

Regards

Irshad

dch3

unread,
Aug 28, 2008, 3:21:01 PM8/28/08
to
I'm not familar with the code that you refer to, however if its using the
Outlook object model to create a MailItem, the .Send Property is the one that
actually sends the email. If its in the code, replace it with .Display.

See...
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._mailitem.display.aspx

If you need code to actually create the MailItem see...
http://msdn.microsoft.com/en-us/library/aa220082(office.11).aspx

To attach the file, see
http://msdn.microsoft.com/en-us/library/aa210901(office.11).aspx

Patricio

unread,
Aug 29, 2008, 1:05:01 PM8/29/08
to
Hope this help you
Sub SendingMail()

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
myItem.to = "irshad...@ggcompany.com"
myItem.cc = "naaeem...@ggcompany.com"
myItem.Subject = "Job-" & Me.JobNo & "-ClaimRef." & Me.ClaimRefNo.Value
myItem.body = "Reference is made to subject claim, attached pls. find
the claim form as pdf" + Chr(13) + "Thanks" + Chr(13) + "Irshad"
myItem.Attach = "C:\WsImpFiles\MyClaimedPDF\" & "Job-" & Me.JobNo &

"-ClaimRef." & Me.ClaimRefNo.Value & ".PDF"

myItem.Send

End Sub

Regards

Patricio

unread,
Aug 29, 2008, 1:17:01 PM8/29/08
to
Ups, sorry, having problems whit attachements, try this one

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)

Set Attamm = myItem.attachments


myItem.to = "irshad...@ggcompany.com"
myItem.cc = "naaeem...@ggcompany.com"
myItem.Subject = "Job-" & Me.JobNo & "-ClaimRef." & Me.ClaimRefNo.Value
myItem.body = "Reference is made to subject claim, attached pls. find
the claim form as pdf" + Chr(13) + "Thanks" + Chr(13) + "Irshad"

setnewAttacment = Attamm.Add("C:\WsImpFiles\MyClaimedPDF\" & "Job-" &
Me.JobNo & "-ClaimRef." & Me.ClaimRefNo.Value & ".PDF", olbyvalue)
myItem.Send

Irshad Alam

unread,
Aug 30, 2008, 3:24:06 AM8/30/08
to
Thank your for advise.

I copied this code and tried, but the following error occured

1. Its is opening/making the mail in Ms Outlook, While I need the same to
be done in Outlook express 6.

2. Above when I tested, found that it is getting shortcut attached of the
file, not the file is getting attached.

3. The body line code is not perfect, it producing error, I modified little
for one line only, then it worked, so for adding second and third line pls.
revise/edit the code

I request you all to kindly advise on the above, so that I can complete this
by sending the pdf by outlookexpress 6 with the complete coding. This will
make me one click complete automatation to reach on outlook express screen
with the detail filled.

Regards

Irshad

Irshad Alam

unread,
Aug 31, 2008, 2:41:00 AM8/31/08
to
pls. advise..waiting to complete it.

Regards

Irshad

Patricio

unread,
Sep 1, 2008, 9:50:01 AM9/1/08
to

Hi, my mistake, i suppouse that you are working in Outlook, it semm to me
that i must to change the object.

Set myOlApp = CreateObject("Outlook.Application")

lets me work , i hope to help you soon

Regards

Patricio

unread,
Sep 1, 2008, 11:45:00 AM9/1/08
to
Sorry , try this one


Sub SendMailWhitOE6()

MAPISession1.UserName = "your...@yourmailserver.com"
MAPISession1.NewSession = True
MAPISession1.DownLoadMail = False
MAPISession1.SignOn
MAPIMessages1.SessionID = MAPISession1.SessionID

MAPIMessages1.MsgIndex = -1 ' new message
MAPIMessages1.RecipDisplayName =
"irshad...@ggcompany.com;naaeem...@ggcompany.com"

MAPIMessages1.ResolveName '
MAPIMessages1.MsgSubject = "Job-" & Me.JobNo & "-ClaimRef." &
Me.ClaimRefNo.Value
MAPIMessages1.MsgNoteText = "Reference is made to subject claim, attached

pls. find the claim form as pdf" + Chr(13) + "Thanks" + Chr(13) + "Irshad"


MAPIMessages1.AttachmentIndex = 0 '
MAPIMessages1.AttachmentName = "Job-" & Me.JobNo & "-ClaimRef." &
Me.ClaimRefNo.Value & ".PDF"
MAPIMessages1.AttachmentPathName = "C:\WsImpFiles\MyClaimedPDF\" & "Job-" &

Me.JobNo & "-ClaimRef." & Me.ClaimRefNo.Value & ".PDF"

MAPIMessages1.AttachmentPosition = 0
MAPIMessages1.AttachmentType = 0
MAPIMessages1.Send


MAPISession1.SignOff

End Sub

Patricio

unread,
Sep 1, 2008, 3:20:00 PM9/1/08
to
Is Ok??

Irshad Alam

unread,
Sep 2, 2008, 12:55:01 AM9/2/08
to
Hi Sir.

thank you reply. I copied from your reply and pasted the below code and it
did not work - Producing error on the first line (highlighting yellow) -
error no. : "RunTime Error 424 - Object Required":

Private Sub Label65_Click()
MAPISession1.UserName = "adhserv...@galadarigroup.com"


MAPISession1.NewSession = True
MAPISession1.DownLoadMail = False
MAPISession1.SignOn
MAPIMessages1.SessionID = MAPISession1.SessionID

MAPIMessages1.MsgIndex = -1 ' new message
MAPIMessages1.RecipDisplayName =
"irshad...@ggcompany.com;naaeem...@ggcompany.com"

MAPIMessages1.ResolveName '
MAPIMessages1.MsgSubject = "Job-" & Me.JobNo & "-ClaimRef." &
Me.ClaimRefNo.Value
MAPIMessages1.MsgNoteText = "Reference is made to subject claim, attached
pls. find the claim form as pdf" + Chr(13) + "Thanks" + Chr(13) + "Irshad"
MAPIMessages1.AttachmentIndex = 0 '
MAPIMessages1.AttachmentName = "Job-" & Me.JobNo & "-ClaimRef." &
Me.ClaimRefNo.Value & ".PDF"
MAPIMessages1.AttachmentPathName = "C:\WsImpFiles\MyClaimedPDF\" & "Job-" &
Me.JobNo & "-ClaimRef." & Me.ClaimRefNo.Value & ".PDF"
MAPIMessages1.AttachmentPosition = 0
MAPIMessages1.AttachmentType = 0
MAPIMessages1.Send


MAPISession1.SignOff

End Sub

Please correct my code and advice, so that I can complete it at earliest

Regards

Irshad

Patricio

unread,
Sep 2, 2008, 10:31:01 AM9/2/08
to
Outlook Express is your default email program?

I still working to help you,

Regards

Patricio

unread,
Sep 2, 2008, 12:45:08 PM9/2/08
to
Still trying :)

Sub SendMailCDO()

FromWhom = "Irshad"
AttachmentPath = "C:\WsImpFiles\MyClaimedPDF\" & "Job-" & Me.JobNo &

"-ClaimRef." & Me.ClaimRefNo.Value & ".PDF"

Body = "Reference is made to subject claim, attached pls. find the claim

form as pdf" + Chr(13) + "Thanks" + Chr(13) + "Irshad"

Subject = "Job-" & Me.JobNo & "-ClaimRef." & Me.ClaimRefNo.Value

ToWhom = "irshad...@ggcompany.com;naaeem...@ggcompany.com"

Const cdoDefaults = -1
Const cdoIIS = 1
Const cdoOutlookExpress = 2

Dim Message As Object 'CDO.Message

Set Message = CreateObject("CDO.Message")

With Message
'Use default configuration from system
'until I learn otherwise

.Configuration.Load -1

.to = ToWhom
If Len(FromWhom) > 0 Then
.from = FromWhom
End If
.Subject = Subject
.TextBody = Body
If Len(AttachmentPath) > 0 Then
.AddAttachment AttachmentPath
End If

.Send
End With
End Sub


Be sure you has CDO objects registred in Access

Irshad Alam

unread,
Sep 3, 2008, 4:54:01 AM9/3/08
to
Sir,

Sorry, I dont know how to register the CDO with Access. You can guide me on
this, so that I can register and test the code.

Regards

Irshad

Patricio

unread,
Sep 3, 2008, 8:34:01 AM9/3/08
to
Tri it, please

Irshad Alam

unread,
Sep 4, 2008, 12:22:05 AM9/4/08
to
Sir,

I could not understand, what to try.

Please guide.

Regards

Irshad

Patricio

unread,
Sep 4, 2008, 8:20:01 AM9/4/08
to
Try last code , please. Then we decide

Irshad Alam

unread,
Sep 7, 2008, 12:51:03 AM9/7/08
to
Sir,

Still waiting for your reply.

Please advise

Regards

Irshad

Patricio

unread,
Sep 8, 2008, 8:20:01 AM9/8/08
to
Try this please

Sub SendMailCDO()

.Configuration.Load -1

Patricio

unread,
Sep 10, 2008, 2:49:03 PM9/10/08
to
Sorry, i think my last message was no published.

Irshad, please this the code. If didn't work i'll help you


Sub SendMailCDO()

.Configuration.Load -1

Patricio

unread,
Sep 15, 2008, 1:42:11 PM9/15/08
to
I dont have any news from my last message ( 9/10/2008 ), So i want to know if
you tryed last code thet i sendt and if it works. Please send a reply .

Irshad Alam

unread,
Sep 16, 2008, 6:28:04 AM9/16/08
to
I dont know what mistake I am making, its not working.

Any mdb sample you can provide so solve this. pls. advice

regards

Irshad

0 new messages