Avatar billede daniel_d Nybegynder
26. februar 2005 - 17:42 Der er 25 kommentarer og
1 løsning

email via outlook - mangler min autosignatur

Jeg har fundet 2 forskellige metoder som begge virker til, at sende en email til en adresse fra en formular i Access. Så vidt så godt, men problemet er, at med begge metoder forsvinder min autosignatur fra emailen.

Kan jeg på nogen måde få min autosignatur med i de mails der laves via Access?

Koderne jeg har leget lidt med - den "inaktive" er min foretrukne

Private Sub Kommandoknap681_Click()
On Error GoTo Err_Kommandoknap681_Click

    'Dim stAppName As String
    'stAppName = "C:\Programmer\Microsoft Office\Office\OUTLOOK.EXE"
   
    'Dim StEmail As String
    'Dim Headline As String
    'Dim Notes As String
    'Dim StrInput As String, StrMsg As String
    'StEmail = Me!Email
    'Headline = "testbesked"
    'Notes = "Beskeden"
    'DoCmd.SendObject , , acFormatRTF, StEmail, "CC", "BCC", Headline, Notes, True
   
    Dim strInput As String
    strInput = "mailto:" & Me!Email & "?subject=Tilmeld dig vores nyhedsbrev?&body='Du skal blot besvare denne mail, så modtager du fremover vores nyhedsbrev!'"
    Application.FollowHyperlink strInput

Exit_Kommandoknap681_Click:
    Exit Sub

Err_Kommandoknap681_Click:
    MsgBox Err.Description
    Resume Exit_Kommandoknap681_Click
   
End Sub
Avatar billede terry Ekspert
26. februar 2005 - 17:58 #1
not sure why these methods dont work, but this method seems to.

Function SendMail()
Dim objOl As New Outlook.Application
Dim objPost As MailItem
Dim vedhæftet As Attachments
       
    Set objPost = objOl.CreateItem(olMailItem)
   
    Set vedhæftet = objPost.Attachments
    'vedhæftet.Add "C:\test.txt"
   
    With objPost
        .Subject = "Subject goes here"
        .To = "eksperten@NOSPAMsanthell.dk"
        .Body = "Hej Med dig!"
       
        .Display
    End With
 
    Set objPost = Nothing
    Set vedhæftet = Nothing
   
Exit Function
Avatar billede terry Ekspert
26. februar 2005 - 17:59 #2
you need a reference to Outlook to use this.
Avatar billede daniel_d Nybegynder
26. februar 2005 - 18:00 #3
Hi Terry - can you please tell me how to make a reference to outlook?
Avatar billede terry Ekspert
26. februar 2005 - 18:06 #4
hi :o)
In the tools+references menu you should be able to find Microsoft Outlook in the list. Just check the box beside it!

This this teh menu in the VBA (code) window
Avatar billede daniel_d Nybegynder
26. februar 2005 - 18:10 #5
The problem is the menu link references is gray = can't click it
Avatar billede daniel_d Nybegynder
26. februar 2005 - 18:11 #6
ahhh  my mistake - I was debugging when trying to make a reference - thats why :o)
Avatar billede terry Ekspert
26. februar 2005 - 18:12 #7
you can also change
.Display
to .send to just send the mail without looking at it.
Avatar billede daniel_d Nybegynder
26. februar 2005 - 18:13 #8
It works, but still no autosignature :o(
Avatar billede terry Ekspert
26. februar 2005 - 18:13 #9
if you want to attach files then you need to remove the comment from this line and change the file name too

'vedhæftet.Add "C:\test.txt"
Avatar billede terry Ekspert
26. februar 2005 - 18:15 #10
strange, I just tested here and it works fine! I didnt get an autosignature with docmd.sendobject

You obviously have an autosignature which gets used when you create a new mail not just reply?
Avatar billede daniel_d Nybegynder
26. februar 2005 - 18:18 #11
yes, my autosignature is used both on new email and on reply - but may be the problem is that my signature is containing HTML ?
Avatar billede daniel_d Nybegynder
26. februar 2005 - 18:20 #12
No, that wasn't the case - just tested with a plain text autosignature...
Avatar billede terry Ekspert
26. februar 2005 - 18:20 #13
maybe, but I dont see why. I just mad a new signature and it works just fine. You could try altering it to plain text
Avatar billede terry Ekspert
26. februar 2005 - 18:21 #14
I'm off out VERY shortly but will take a look tomorrow, or maybe this evenin if I find time.
Hope you get it working
Avatar billede daniel_d Nybegynder
26. februar 2005 - 18:21 #15
I'm using Office 2003 Danish version it that's important
Avatar billede daniel_d Nybegynder
26. februar 2005 - 18:24 #16
ok, but thanks for your time and help so far...
Avatar billede daniel_d Nybegynder
26. februar 2005 - 18:26 #17
If I remove the body text from the function then the signature will appear. The same was the case with this method:

    'Dim strInput As String
    'strInput = "mailto:" & Me!Email & "?subject=Tilmeld dig vores nyhedsbrev?&body='Du skal blot besvare denne mail, så modtager du fremover vores nyhedsbrev!'"
    'Application.FollowHyperlink strInput

Very strange...
Avatar billede daniel_d Nybegynder
26. februar 2005 - 18:37 #18
I seem to have found what causing the problem. When using word as my email editor, the signature is lost - as soon as I removed word as my editor the signature appeared...

But would like to use word though... still this is better than nothing.
Avatar billede daniel_d Nybegynder
26. februar 2005 - 18:39 #19
opps... is still don't work - I tested it with no body text, when added body text I still had no autosignature... :o(
Avatar billede daniel_d Nybegynder
26. februar 2005 - 19:16 #20
Det lader ikke til, at man kan lave en forud bestemt tekst i body og beholde sin autosignatur.

I mit tilfælde er der tale om en række stadard breve, så jeg tænkte om man i stedet kunne åbne et gemt brev hvor teksten var skrevet i selve brevet istedet for access leverer teksten???

Access skal stadig levere adressen til modtageren.

Er dette muligt
Avatar billede terry Ekspert
27. februar 2005 - 09:18 #21
Morning
It may be possible to add the autosignature AFTER adding the body text. You could also try adding an empty line or two, to your autosignature.

I'll get back a bit later after I have played around a bit
Avatar billede terry Ekspert
27. februar 2005 - 12:41 #22
Here is a simple solution which you may be able to use


.Body = "Body of text goes here" & .Body 'so we keep the autosignature which is obviosuly getting over-written
Avatar billede daniel_d Nybegynder
27. februar 2005 - 13:33 #23
Hi Terry
Thats the same solution I found during the night :o)
But cause my signature is HTML I changed

.Body = "" to .HTMLBody = ""
Then I just made a copy of my signature and placed it here, but if I were to change my signature later it will painfull having to change it many places. But for now it work and it seems to be the only working solution.

Thank's for your time and work.
Avatar billede daniel_d Nybegynder
27. februar 2005 - 13:46 #24
BTW can you see were my mistake is? I'm trying to move the autosignature out of the sendmail function into a sub, so it would be easier to edit.


Sub Autosignature(HTML)
    Dim HTML
    HTML = "My HTML signature"
End Sub

Function SendMail()
Dim objOl As New Outlook.Application
Dim objPost As MailItem
Dim vedhæftet As Attachments
       
    Set objPost = objOl.CreateItem(olMailItem)
    Set vedhæftet = objPost.Attachments
    'vedhæftet.Add "C:\test.txt"
   
    With objPost
        .Subject = "Subject goes here"
        .To = "my@email.dk"
        .HTMLBody = "Selve teksten" & Autosignature(HTML)
        .Display
    End With
 
    Set objPost = Nothing
    Set vedhæftet = Nothing
   
End Function
Avatar billede terry Ekspert
27. februar 2005 - 14:45 #25
Maybe something like this

Function Autosignature() as String
   
    Autosignature = "My HTML signature"

End Sub


and thanks
Avatar billede daniel_d Nybegynder
27. februar 2005 - 14:49 #26
That did the trick... thanks
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester