Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-03-2019, 02:31 AM
Browny38 Browny38 is offline Unsubscribe code for newsletter Windows 10 Unsubscribe code for newsletter Office 2016
Novice
Unsubscribe code for newsletter
 
Join Date: Jan 2019
Posts: 3
Browny38 is on a distinguished road
Default Unsubscribe code for newsletter

Hi I am starting up a monthly newsletter and want to add a unsubscribe button in Vba
I can get the button in position but need the code. Help appreciated.
I have written this but it needs editing.
Sub UnsubEmail ()
Dim c1App As Outlook.Application
Dim c1Mail As Outlook.MailItem
Set c1App = CreateObject(“Outlook.Application”)
Set c1Mail = c1App.CreateItem(c1MailItem)
c1Mail.To = My Email


c1mail.Subject = “Unsubscribe”
c1Mail.Body = “Unsubscribe this person”
c1Mail.Send
‘Clean Up
Set c1App = Nothing
Set c1Mail = Nothing
End Sub

Last edited by Browny38; 01-03-2019 at 05:19 PM.
Reply With Quote
  #2  
Old 01-05-2019, 02:54 AM
Browny38 Browny38 is offline Unsubscribe code for newsletter Windows 10 Unsubscribe code for newsletter Office 2016
Novice
Unsubscribe code for newsletter
 
Join Date: Jan 2019
Posts: 3
Browny38 is on a distinguished road
Default Newsletter in Word needs an unsubscribe vb code for a button.

Hi I feel I am getting close to the answer with this code, but it still needs to be corrected.

Private Sub CommandButton1_Click()
Dim OL As Object
Dim EmailItem As Object
Dim abc As String
'To add to a Word newsletter an Unsubscribe button
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Application.UserName = "abc"
With EmailItem
.Subject = "Unsubscribed"
.Body = "This person has unsubbed"
.To = "my email@xzy.com"
.Importance = olImportanceNormal
.Attachments.Add abc
.Send
End With
Application.ScreenUpdating = True
End Sub
Reply With Quote
  #3  
Old 01-05-2019, 07:29 AM
gmayor's Avatar
gmayor gmayor is offline Unsubscribe code for newsletter Windows 10 Unsubscribe code for newsletter Office 2016
Expert
 
Join Date: Aug 2014
Posts: 3,472
gmayor is a name known to allgmayor is a name known to allgmayor is a name known to allgmayor is a name known to allgmayor is a name known to allgmayor is a name known to all
Default

Frankly I wouldn't add a button as you cannot force users to run your macros. A hyperlink to your e-mail address would be a more certain bet and no macros required e.g.

{ HYPERLINK "mailto:me@somewhere.com?subject=Unsubscribe" \o "Click here to unsubscribe from this newsletter" }
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #4  
Old 01-05-2019, 05:05 PM
Browny38 Browny38 is offline Unsubscribe code for newsletter Windows 10 Unsubscribe code for newsletter Office 2016
Novice
Unsubscribe code for newsletter
 
Join Date: Jan 2019
Posts: 3
Browny38 is on a distinguished road
Default

Hi Graham, thank you for the wording. I have 2 computers at home and I sent the newsletter and clicked the unsubscribe link and then a security question appeared and I had to click Y which then went to an email ready to send with another click. I received the email on the other computer. Great. Can I do away with the 2 mouse clicks and just have the link clicked and the rest is automatic?
Browny38
Reply With Quote
  #5  
Old 01-06-2019, 03:17 AM
gmayor's Avatar
gmayor gmayor is offline Unsubscribe code for newsletter Windows 10 Unsubscribe code for newsletter Office 2016
Expert
 
Join Date: Aug 2014
Posts: 3,472
gmayor is a name known to allgmayor is a name known to allgmayor is a name known to allgmayor is a name known to allgmayor is a name known to allgmayor is a name known to all
Default

The hyperlink security message can be switched off on your own computers using a registry hack (see below where 16 is the Office version), but you cannot switch it off on the recipients computers. How they have their security options configured is a matter for them to determine.


HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\C ommon
Beneath Common, locate the Security subkey. If there isn't a Security subkey, create it.
Beneath Security, add a new DWORD value named DisableHyperlinkWarning and set its value to 1
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unsubscribe code for newsletter Electronic Newsletter MaineLady Word 1 09-11-2016 06:16 PM
Problems sending html newsletter vanderloo Outlook 0 11-08-2012 11:31 AM
unneccesary gap in newsletter, please help! slain Outlook 0 05-07-2011 03:44 AM
Email marketing help - "Unsubscribe" Footer DoughMan Outlook 0 04-06-2011 10:57 AM
Unsubscribe code for newsletter Curve the Text Box in a Newsletter? lewiedude Publisher 2 11-08-2005 08:52 AM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 10:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft