ASP to Word send by ObjSendMail ??

Discussion in 'ASP General' started by Jerry Yang, Aug 27, 2008.

  1. Jerry Yang

    Jerry Yang Guest

    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
    Jerry Yang, Aug 27, 2008
    #1
    1. Advertising

  2. Gazing into my crystal ball I observed Jerry Yang <>
    writing in news:b692a69c-2866-4f4e-945f-98696c32280b@
    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.

    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
    Adrienne Boswell, Aug 28, 2008
    #2
    1. Advertising

  3. "Jerry Yang" <> wrote in message
    news:...
    > 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.


    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, Aug 28, 2008
    #3
  4. Jerry Yang

    Jerry Yang Guest

    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
    Jerry Yang, Aug 29, 2008
    #4
  5. "Jerry Yang" <> wrote in message
    news:...
    > 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 <>"
    oMsg.To = "Bloke <>"
    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.

    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, Aug 29, 2008
    #5
  6. Jerry Yang

    Jerry Yang Guest

    Cheers that works well :)

    Should keep him off my back for a while !!
    THANKS
    Jerry Yang, Aug 31, 2008
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laura
    Replies:
    1
    Views:
    526
    Gunnar Hjalmarsson
    Jun 5, 2004
  2. Stephen Witter

    opening a word doc in word not browser

    Stephen Witter, May 18, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    487
    Stephen Witter
    May 18, 2004
  3. Luis Esteban Valencia
    Replies:
    2
    Views:
    2,940
    sanjupillai
    Sep 26, 2008
  4. Sharon
    Replies:
    0
    Views:
    598
    Sharon
    Jul 27, 2005
  5. Franck
    Replies:
    1
    Views:
    4,844
Loading...

Share This Page