ASP to Word send by ObjSendMail ??

J

Jerry Yang

Hi

I can get the data I need from my DB and show it on screen fine.

One user has asked if I can have an option when the submits his new
data to the DB, instead of it emailing him a plain text or html email,
(as it does now) could it send a copy of the data as a word doc.

Can any one help ??

Server is windows 2003

Thanks
 
A

Adrienne Boswell

Gazing into my crystal ball I observed Jerry Yang <[email protected]>
writing in 56g2000hsm.googlegroups.com:
Hi

I can get the data I need from my DB and show it on screen fine.

One user has asked if I can have an option when the submits his new
data to the DB, instead of it emailing him a plain text or html email,
(as it does now) could it send a copy of the data as a word doc.

Can any one help ??

Server is windows 2003

Thanks

Google is your friend. There are plenty of examples. Google for asp
word.
 
A

Anthony Jones

Jerry Yang said:
Hi

I can get the data I need from my DB and show it on screen fine.

One user has asked if I can have an option when the submits his new
data to the DB, instead of it emailing him a plain text or html email,
(as it does now) could it send a copy of the data as a word doc.

Can any one help ??

What the user is asking for is far from a trivial change.

As long as you are sending nicely formatted HTML may advice would be to say
to the user "No sorry I can't do that" and see what happens.
 
J

Jerry Yang

Hi
I have googled this, but can't seem to find what I'm looking for and
this users is the boss !!

So I've got to try and sort something !!

any other ideas ?

thanks
 
A

Anthony Jones

Jerry Yang said:
Hi
I have googled this, but can't seem to find what I'm looking for and
this users is the boss !!

So I've got to try and sort something !!

Since its the boss and not a customer or anyone else important you could
probably get away with using HTML and pretending its a word doc.

Option Explicit

Const cdoSendUsingMethod =
"http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSMTPServer =
"http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPickupDirectory =
"http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory"
Const cdoSMTPServerPort =
"http://schemas.microsoft.com/cdo/configuration/smtpserverport"

Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2


Dim oMsg : Set oMsg = CreateObject("CDO.Message")
Dim oConfig : Set oConfig = CreateObject("CDO.Configuration")

With oConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "mysmtp.myserver.com"
.Item(cdoSMTPServerPort) = 25
.Update
End With

oMsg.From = "Me <[email protected]>"
oMsg.To = "Bloke <[email protected]>"
oMsg.Subject = "Test"
oMsg.HTMLBody = "<html><body>Hello World</body></html>"
Set oMsg.Configuration = oConfig

Dim oPart : Set oPart = oMsg.Attachments.Add

oPart.ContentMediaType = "text/html;charset=Windows-1252"
oPart.ContentTransferEncoding = "quoted-printable"
oPart.Fields("urn:schemas:mailheader:content-disposition") = "attachment;
filename=""test.doc"""
oPart.Fields.Update

Dim oStream : Set oStream = oPart.GetDecodedContentStream

Dim sDoc : sDoc = "<html><body><h1>This is a Header</h1><p>This is
content</p></body></html>"

oStream.WriteText sDoc
oStream.Flush

oMsg.Send


Ok so the attachment is really HTML but since the filename says its .doc its
word that opens it and word quite happily displays simple HTML.
 

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

Members online

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top