+ Reply to Thread
Results 1 to 5 of 5

Sending email with outlook signature

Hybrid View

  1. #1
    Registered User
    Join Date
    08-29-2008
    Location
    WA, USA
    Posts
    14

    Sending email with outlook signature

    hi all

    Function GetBoiler(ByVal sFile As String) As String
    '**** Kusleika
        Dim fso As Object
        Dim ts As Object
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
        GetBoiler = ts.readall
        ts.Close
    End Function
    
    Sub Mail_Outlook_With_Signature_Plain()
    ' Don't forget to copy the function GetBoiler in the module.
    ' Working in Office 2000-2007
        Dim OutApp As Object
        Dim OutMail As Object
        Dim strbody As String
        Dim SigString As String
        Dim Signature As String
     
        Set OutApp = CreateObject("Outlook.Application")
        OutApp.Session.Logon
        Set OutMail = OutApp.CreateItem(0)
     
        strbody = "Hi there" & vbNewLine & vbNewLine & _
                  "This is line 1" & vbNewLine & _
                  "This is line 2" & vbNewLine & _
                  "This is line 3" & vbNewLine & _
                  "This is line 4"
     
        SigString = "C:\Documents and Settings\" & Environ("username") & _
                    "\Application Data\Microsoft\Signatures\Mysig.txt"
     
        If Dir(SigString) <> "" Then
            Signature = GetBoiler(SigString)
        Else
            Signature = ""
        End If
     
        On Error Resume Next
        With OutMail
            .To = "ron@debruin.nl"
            .CC = ""
            .BCC = ""
            .Subject = "This is the Subject line"
            .Body = strbody & vbNewLine & vbNewLine & Signature
            'You can add files also like this
            '.Attachments.Add ("C:\test.txt")
            .Send   'or use .Display
        End With
        On Error GoTo 0
     
        Set OutMail = Nothing
        Set OutApp = Nothing
    End Sub
    This macro sends an email with a body and signature, but this works only if you manually provide the user signature file which is MySig.txt in this macro. My problem is that this same macro would be used by different users. So it should dynamically read the signature file from user's location C:\Documents and Settings\" & Environ("username") "\Application Data\Microsoft\Signatures\[user file]" and send email with that particular user's signature.

    Please guide me as how this could be achieved.
    Last edited by VBA Noob; 09-03-2008 at 02:54 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello sexcel,

    First, let's start with path. You can this better using a different environmental variable - APPDATA. This will return the path to the Application Data folder for the logged on user. Your path to the signatures becomes...
      FilePath = Environ("APPDATA") & "\Microsoft\Signatures\"
    Getting the proper signature file is bit tricker. Each time you create a signature, Outlook creates three different file formats for a single signature: HTML, RTF, and TXT. If you want to use only TXT files that is easy enough. But, what happens when the user has multiple signatures? Do you show all the signatures and have the user pick one?

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    08-29-2008
    Location
    WA, USA
    Posts
    14
    Thanks for helping with the Path.

    Picking up TXT signature file for the specific user will do for time being.

    But it will be good if the email can have the formatted signature (HTML or RTF) in it.

    Please show how to do this.

  4. #4
    Registered User
    Join Date
    08-29-2008
    Location
    WA, USA
    Posts
    14
    hi all

    Could someone please help me with the problem.

  5. #5
    Registered User
    Join Date
    08-29-2008
    Location
    WA, USA
    Posts
    14
    hi all,

    If someone has any idea on this, please elt me know. Atleast how to get the TXT signature dynamically.

    Any help would be highly appreciated.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 07-07-2008, 12:03 PM
  2. looping through range of cells & sending multiple emails with outlook
    By splosczynski in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-03-2008, 01:49 PM
  3. Sending Outlook email pop up box
    By jamphan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-23-2007, 03:56 PM
  4. Problem Sending embedded image via outlook 2003 from Excel 2003 vba
    By sy278 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-23-2007, 06:13 AM
  5. auto tracker function and sending of personalised email from outlook 2000(Urgently)
    By xiaotianshi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2007, 09:11 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1