dcsimg
Results 1 to 8 of 8

Thread: A script seen 1000 times for Outlook.....with a twist....

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2019
    Posts
    4

    A script seen 1000 times for Outlook.....with a twist....

    Ok, I have been pulling out my little bit of hair. The script work perfectly, does exactly what I want it to. Pulls all info from AD properly and formats the table and inserts the logo just as I need it.
    However, I have found out since I have deployed it that the Plain Text reply looks horrible. In other forums I have been informed that this is because Outlook is trying to convert the HTML file to TXT and is doing it badly. They stated that I need to tell the script to save it separately as the three individual files. This is where my issue comes in. I can't for the life of me figure out how to make that happen. I have spent the last 4 days researching to get the right code, but I cannot get anything to work. I really need an assist on this if anyone here would be so kind.

    Here is the script that works.

    Code:
    On Error Resume Next
    
    Set objSysInfo = CreateObject("ADSystemInfo")
    
    strUser = objSysInfo.UserName
    Set objUser = GetObject("LDAP://" + strUser)
    
    strFullName = objUser.Fullname
    strTitle = objUser.Title
    strAdres = objUser.StreetAddress
    strPhone = objUser.TelephoneNumber
    strMain = objUser.homePhone
    strMob = objUser.Mobile
    strOfficeFax = ObjUser.facsimileTelephoneNumber
    strCity = ObjUser.l
    strState = ObjUser.st
    strZip = ObjUser.postalCode
    strLogo = "\\path\to\my\logo\signature.png"
    
    Set objWord = CreateObject("Word.Application")
    Set objDoc = objWord.Documents.Add()
    Set objSelection = objWord.Selection
    Set objEmailOptions = objWord.EmailOptions
    Set objSignatureObject = objEmailOptions.EmailSignature
    Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
    
    
    
    Set objRange = objDoc.Range()
    	objDoc.Tables.Add objRange,6,6
      Set objTable = objDoc.Tables(1)
    
    	objDoc.Styles("Hyperlink").Font.Color = Word.WdColorBlue
    'objSelection.ParagraphFormat.LineSpacing = 10	
    		objdoc.Paragraphs.SpaceAfter = 0
    
    
    	objTable.Cell(1,1).Merge objTable.Cell(2,1) 
    	objTable.Cell(1,1).Merge objTable.Cell(3,1) 
    	objTable.Cell(1,1).Merge objTable.Cell(4,1) 
    	objTable.Cell(1,1).Merge objTable.Cell(5,1) 
    	objTable.Cell(1,1).Merge objTable.Cell(6,1)
    
    	objtable.cell(1,1).width = 122
    	objtable.cell(1,1).ParagraphFormat.Alignment = wdAlignParagraphRight
    
    	objTable.Cell(1,4).Merge objTable.Cell(1,5) 
    	objTable.Cell(1,3).Merge objTable.Cell(1,4) 
    	objTable.Cell(1,2).Merge objTable.Cell(1,3)
    	objTable.Cell(2,4).Merge objTable.Cell(2,5)  
    	objTable.Cell(2,3).Merge objTable.Cell(2,4) 
    	objTable.Cell(2,2).Merge objTable.Cell(2,3)
    	objTable.Cell(3,4).Merge objTable.Cell(3,5) 
    	objTable.Cell(3,3).Merge objTable.Cell(3,4) 
    	objTable.Cell(3,2).Merge objTable.Cell(3,3)
    	objTable.Cell(4,4).Merge objTable.Cell(4,5) 
    	objTable.Cell(4,3).Merge objTable.Cell(4,4) 
    	objTable.Cell(4,2).Merge objTable.Cell(4,3)
    	objTable.Cell(5,4).Merge objTable.Cell(5,5) 
    	objTable.Cell(5,3).Merge objTable.Cell(5,4) 
    	objTable.Cell(5,2).Merge objTable.Cell(5,3)
    	objTable.Cell(6,4).Merge objTable.Cell(6,5) 
    	objTable.Cell(6,3).Merge objTable.Cell(6,4) 
    	objTable.Cell(6,2).Merge objTable.Cell(6,3)
    
    	objTable.Cell(1,1).Range.ParagraphFormat.Alignment = wdAlignParagraphRight
    	objTable.Cell(1,1).Range.InlineShapes.AddPicture(strLogo)
    	
    	objTable.Cell(1,2).Range.Font.Name = "Calibri"
    	objTable.Cell(1,2).Range.Font.Size = "12"
    	objTable.Cell(1,2).Range.Font.Bold = True
    	objTable.Cell(1,2).Range.Text = strFullName 
    	
    	objTable.Cell(2,2).Range.Font.Name = "Calibri"
    	objTable.Cell(2,2).Range.Font.Size = "10"
    	objTable.Cell(2,2).Range.Font.Bold = True
    	objTable.Cell(2,2).Range.Text = strTitle
    		
    	objTable.Cell(3,2).Range.Font.Name = "Calibri"
    	objTable.Cell(3,2).Range.Font.Size = "10"
    	objTable.Cell(3,2).Range.Font.Bold = False
    	objTable.Cell(3,2).Range.Text = strAdres & "  " & strCity & ", " & strState & "  " & strZip
    		
    	objTable.Cell(4,2).Range.Font.Name = "Calibri"
    	objTable.Cell(4,2).Range.Font.Size = "10"
    	objTable.Cell(4,2).Range.Font.Bold = False
    	objTable.Cell(4,2).Range.Text = "Office: " & strMain & " | " & "Fax: " & strOfficeFax 
    
    
    Set objCell = objTable.Cell(5, 2)
    Set objCellRange = objCell.Range
    objCell.Select
    	objTable.Cell(5,2).Range.Font.Name = "Calibri"
    	objTable.Cell(5,2).Range.Font.Size = "8"
    	objTable.Cell(5,2).Range.Font.Bold = False
    	objTable.Cell(5,2).Range.Font.Color = Word.WdColorBlue 'Change font color to Blue
    Set objLink = objSelection.Hyperlinks.Add(objSelection.Range,"www.mywebsite.com" &strWebsite,strWebsite)
    
    Set objSelection = objDoc.Range()
    
    
    objSignatureEntries.Add "Signature2019", objSelection
    objSignatureObject.NewMessageSignature = " Signature2019"
    objSignatureObject.ReplyMessageSignature = "Signature2019"
    objDoc.Saved = True
    objWord.Quit
    That script provides this
    Name:  2019-07-23_8-56-44.jpg
Views: 107
Size:  9.8 KB

    It's perfect.


    But on a Plain Text email reply it does this.
    Name:  TXTReply1.jpg
Views: 104
Size:  26.0 KB

    Our old VBS script didn't do that. It would just pull out the LOGO and leave the text in the same format. However, that script doesn't work on Office 2016 and above.

    This is the piece of the old script that is different from the new one.

    Reply Signature
    Code:
    Set objDoc = objWord.Documents.Add()
    Set objSelection = objWord.Selection
    Set objEmailOptions = objWord.EmailOptions
    Set objSignatureObject = objEmailOptions.EmailSignature
    Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
    objSelection.Style = "No Spacing"
    objSelection.Font.Name = "Calibri"
    objSelection.Font.Size = "11"
    objSelection.Font.Bold = True
    objSelection.TypeText strName
    if (strCred) then objSelection.TypeText ", " & StrCred
    objSelection.TypeParagraph()
    objSelection.Font.Bold = False
    objSelection.TypeText strTitle
    objSelection.TypeParagraph()
    objSelection.TypeText strCompany
    objSelection.TypeParagraph()
    objSelection.TypeText "Office: " & strPhone
    objSelection.TypeParagraph()
    if (strMobile) then objSelection.TypeText "Cell: " & strMobile
    Set objSelection = objDoc.Range()
    objSignatureEntries.Add "Standard Reply", objSelection
    I have tried to add that to my script, but now it does a pop up a box asking to save the TXT file as a name. I can't have that.

    So to summarize.
    My script works perfectly. I need a way to have it save as TXT properly so that the reply signature works proper as HTML and RTF emails and then has the properly formatted text in a Plain text email reply.


    Thank you so much to anyone that can assist. I truly appreciate it. My brain is mush trying to figure this out.

    **EDIT** I fixed all my picture errors. Sorry about that. This has now become a critical issue as the VP/COO has now seen it and is not happy. So if anyone can shed some light on this I will be so very appreciative!!

    Thanks!!

    Jay
    Last edited by signalcc; Aug 2nd, 2019 at 12:48 PM. Reason: Removed email and contact info

  2. #2
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,688

    Re: A script seen 1000 times for Outlook.....with a twist....

    Welcome to the Forums.

    I had to remove the contact information from the attachment as per our forum rules and to keep that info safe. I also added [code] tags to format your code properly and easier to read.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2019
    Posts
    4

    Re: A script seen 1000 times for Outlook.....with a twist....

    Yea I saw that after I submitted. I also resubmitted with it done right. Not sure if you want to use that post instead....lol THanks!!

  4. #4
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,688

    Re: A script seen 1000 times for Outlook.....with a twist....

    Its ok I already formatted the post and the other one was deleted. No biggie

    Maybe redo the attachments so no contact info is shown?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2019
    Posts
    4

    Re: A script seen 1000 times for Outlook.....with a twist....

    I don't see a way to edit it and at the bottom it says I cannot edit my posts. Guess I don't have the permissions....

  6. #6

    Thread Starter
    New Member
    Join Date
    Aug 2019
    Posts
    4

    Re: A script seen 1000 times for Outlook.....with a twist....

    Sorry to bump this, but I really need some help. The VP/COO is up my backside about this and I can't find any answers. Can anyone point me in the right direction? I would really appreciate it.
    Thanks!!

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,444

    Re: A script seen 1000 times for Outlook.....with a twist....

    script to save it separately as the three individual files.
    afaik this can not work unless you know to whom to send each of the files, so if you do not know if the recipient has setting for text only how can you use separate body content?

    i would suggest to start by simplifying your document, firstly by omitting all the merged cells as i am sure converting those to text would be sure to cause an issue

    don't worry about the code until you find what can work better, manually working with the word document
    you could probably also simplify your code by opening each new document based on a specific template, that already includes the tables and other fixed data

    as i do not have office 2016 and am unlikely to get it within the near future, if at all, i can not help with any specifics, many of the others here may be in the same position, not upgrading programs is one of the many reasons to still be using vb6

    if this code is a vbs script, someone will probably point out this is the forum for vb6, though most of the code should be fully compatible
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  8. #8
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,327

    Re: A script seen 1000 times for Outlook.....with a twist....

    Moved to Office section. You're likely to get a little more help here. It could also belong in our dedicated VBScript section. If you'd rather it was moved there just hit the report button (the little exclamation in the triangle) and let us know.

    Welcome to the forums.
    You can depend upon the Americans to do the right thing. But only after they have exhausted every other possibility - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width